I have a pager with two fragments, each with its own xml. My question is, is it possible to programmatically switch from one fragment to another and start any listener?
Best wishes
I assume you mean ViewPager . You can switch between them using pager.setCurrentItem (index)
If you are using ViewPager , you can try setSelectedNavigationItem() . That is, you can switch from one fragment to another by calling:
ViewPager
setSelectedNavigationItem()
int position = 0; // position of the tab you want ((ParentActivity) getActivity()).getActionBar().setSelectedNavigationItem(position);
or, if you use ActionBarSherlock:
int position = 0; // position of the tab you want ((ParentActivity) getActivity()).getSupportActionBar().setSelectedNavigationItem(position);
You need to set the current item in the ViewPager, and then you need to notify the adapter so that it brings a new fragment.
ViewPager ViewPager; FragmentPagerAdapter adapter; pager.setCurrentItem(2); adapter.notifyDataSetChanged();
Source: https://habr.com/ru/post/904934/More articles:Trunk relational: an association key will not work if it does not match the foreign key - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/904930/sql-server-2012-separate-2-varcharmax-columns-to-separate-table&usg=ALkJrhgbTYRNDLO4bbRvQYF95gcm5xK_awAndroid value ScanResult.level - androidWhat is the advantage of having a varbinary field in a separate table 1-1? - performanceWhy are my log4net log entries displayed in Chainsaw on Windows 7 - windows-7PHP script cannot get output from Python script - pythonseparate table for image elements with image field - performanceone database for each client or all clients in one database. which should i use for online application? - mysqlHow to set a push button switch inside a QMenu or QAction controller? - user-interfaceUsing CSS content to style a hierarchical nested list - htmlAll Articles