正则表达式:在第一个空行后匹配所有内容(Regex: Match everything after first blank line)
我正在尝试创建一个匹配所有内容的正则表达式,但不包括c#中的第一个空行。
例:
输入:
This is header info that I dont' : really want in my file I want everything below this line until the end of the file even this stuff
会导致:
I want everything below this line until the end of the file even this stuff
I am trying to create a regex that matches everything after but not including the first blank line in c#.
Example:
having input of:
This is header info that I dont' : really want in my file I want everything below this line until the end of the file even this stuff
would result in:
I want everything below this line until the end of the file even this stuff
原文:https://stackoverflow.com/questions/39459949
最满意答案
我找到了答案。 如果
isDetached()
为true,那么并不意味着getParentFragment()
不为null。因此,而不是以前的
testMethod()
检查,这是新的代码:public void testMethod() { if (isDetached() && getParentFragment() != null) { return; } ... }
我现在也在
Fragment0
中的onStart()
方法中再次调用相同的方法,其中getParentFragment()
不应该为null。I found the answer. If
isDetached()
is true, it doesn't meangetParentFragment()
is not null.So instead of the previous check in
testMethod()
, this is the new code:public void testMethod() { if (isDetached() && getParentFragment() != null) { return; } ... }
I also now call the same method again in the
onStart()
method withinFragment0
, wheregetParentFragment()
should not be null.
相关问答
更多-
请检查下面的链接,它对你的问题有很好的解释: http://tamsler.blogspot.in/2011/11/android-viewpager-and-fragments-part-ii.html 或者你可以尝试下面的代码片段: 1.在视图寻呼机或视图寻呼机适配器中添加片段: MyFragment myFragment = MyFragment.newInstance(); mPageReferenceMap.put(index, "Some Tag"); getSupportFragmentMan ...
-
将将侦听器添加到数据库的代码( addValueEventListener )移动到片段的OnAttach方法中。 根据您使用ViewPager的方式, FragmentPagerAdapter可能决定“回收”您的碎片。 因此,当从Activity( OnDetach )分离片段时,删除数据库侦听器非常重要。 看起来像数据库是一个单身人士,所以听众可能会超出你的片段甚至活动。 可能导致一些内存泄漏。 所以记得要确定地移除听众。 Move the code that adds the listener to ...
-
在这里查看答案以获得一些很好的解决方案: ViewPager PagerAdapter不更新视图 基本上在你的PagerAdapter覆盖getItemPosition会给你想要的效果。 public int getItemPosition(Object object) { return POSITION_NONE; } Check the answers here for some good solutions: ViewPager PagerAdapter not updating the ...
-
我已经在这里找到了解决方案,但是也会在这里发布,以便其他用户查看代码并且不会像我那样陷入困境数周。 MyPagerAdapter.java public class MyPagerAdapter extends FragmentPagerAdapter { private Context context; final LatLng YEREVAN = new LatLng(40.181, 44.513); public MyPagerAdapter(FragmentManag ...
-
我认为我的问题是我在我的活动的onCreate中调用了这个adapter.getRegisteredFragment(position),而在onCreate中,viewpager仍然没有完全加载,并且仍然没有实例化registeredFragments,所以列表仍然是空的.. 如果在viewpager完全加载时将此调用移动到另一个位置,它将起作用。 I think my problem was that I was calling this adapter.getRegisteredFragment(po ...
-
getItem必须返回Fragment的实例,而不是null。 将其更改为: @Override public Fragment getItem(int arg0) { // TODO Auto-generated method stub Fragment frag=null; if (arg0 == 0) { frag = new TAB_1(); } else if(arg0 == 1) { frag = new TAB_2(); ...
-
我找到了答案。 如果isDetached()为true,那么并不意味着getParentFragment()不为null。 因此,而不是以前的testMethod()检查,这是新的代码: public void testMethod() { if (isDetached() && getParentFragment() != null) { return; } ... } 我现在也在Fragment0中的onStart()方法中再次调用相同的方法,其中getPar ...
-
您需要在所需的屏幕上覆盖onPageSelected方法和激发尊重的方法,例如: @Override public void onPageSelected(int position) { if (position == 0) { callForPage(); } else if (position == 1) { callForPage1(); } } 您可以使用以下代码转到所选屏幕。 viewPager.setCurrentItem(pageposi ...
-
片段在viewPager.setOnPageChangeListener()中返回null(Fragment return null in viewPager.setOnPageChangeListener())[2022-07-01]
解决方案1 ListFragment listFragment = (ListFragment) pagerAdapter.instantiateItem(viewPager, position) 解决方案2这是一个黑客攻击 ListFragment listFragment = (ListFragment) getSupportFragmentManager().findFragmentByTag( "android:switcher:" + R.id.viewpager + ":" + ... -
如果您使用少量片段,则可以实现FragmentPagerAdapter 。 为了显示更大数量的片段,建议使用FragmentStatePagerAdapter 。 您可以将所有片段保存在一个类(Activity类)中,并使每个片段成为该类的子类,但我认为在各自的.java文件中使用不同的类会使您的代码更加优雅。 初始化片段通常在fragmentTransaction期间完成,并且适当的数据通过Bundle传递。 If you are using a small number of fragments the ...