V
V
Vadim0282014-09-22 13:25:11
Android
Vadim028, 2014-09-22 13:25:11

How to get to the ListView element by ID located in the ListAdapter that is loaded into the FragmentTabsPager?

Help to get to the ListView element (by ID?), from the FragmentTabsPager "Activity" (SherlockFragmentActivity), to determine the coordinates of the list element received through the ListAdapter. It is required to supply this data to the target input for ShowcaseView.

Screenshot of listbox, first item highlighted for example
a4442549154e47b5a0bbac303a5a0ca1.png

The list is formed in LoaderCursorSupport.java (CursorLoaderListFragment extends SherlockListFragment) upon request from FragmentTabsPager.java to populate the ViewPager (@+id/pager in the XML markup) and populate the specified tab with content.
All elements from the fragment_tabs_pager.xml markup can be found, but it does not see what is in the list either through the search by ID or through the search for fragments.
Tried both in onCreate() and onStart()
Fragments are not found at all:
Fragment frag1 = getSupportFragmentManager().findFragmentById(R.id.pager); 

//Если фрагмент не существует (null) или не является частью разметки (isInLayout), то переменная mIsDynamic будет иметь значение true.
mIsDynamic = frag1 == null || !frag1.isInLayout();

Toast.makeText(this, mIsDynamic + " не неайдено", Toast.LENGTH_SHORT).show();

Searches by ID only within the "fragment_tabs_pager.xml" markup, and elements that are inserted as "ViewPager" (android:id="@+id/pager") are not visible
ViewPager vp = (ViewPager) this.findViewById(R.id.pager); //находит

TextView tv   = (TextView) vp.findViewById(R.id.Text1); //возвращает NullPointerException
TextView tv   = (TextView) this.findViewById(R.id.Text1); //возвращает NullPointerException

The code from the example for the ABS 4.4 library (fragments), the files used are at the links:
FragmentTabsPager.java
LoaderCursorSupport.java
fragment_tabs_pager.xml

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sp0tted_0wl, 2014-09-25
@Sp0tted_0wl

So have you tried it?

ViewPager vp = (ViewPager) this.findViewById(R.id.pager); //находит

Fragment currentFragment = vp.getAdapter().getItem(vp.getCurrentItem());
View fragmentView = currentFragment.getView

TextView tv = (TextView) fragmentView.findViewById(R.id.Text1);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question