android fragments - Where should I put my code in ActionBar.TabListener -



android fragments - Where should I put my code in ActionBar.TabListener -

i have started actionbar.tablistener 3 tabs. selected new "tabbed activity" in android studio. activity called test...not best name i'm trying learn:)

i have listview in fragment_test.xml want fill info after raw sql search. if set code in oncreateview everytime click on tab re-write tab same info in listview. want have diffrent info in tabs.... need know tab clicked. did mviewpager.getcurrentitem() ....is right? how can name of tab instead?

i have found ontabselected...should set code here? in case think know tab selected wise set code here? if listview1 becomes null...why?:

public void ontabselected(actionbar.tab tab, fragmenttransaction fragmenttransaction) { listview1 = (listview)findviewbyid(r.id.listview2); listadapter2 = new arrayadapter<string>(context, r.layout.simplerow, testarray); listadapter2.notifydatasetchanged(); listview1.setadapter(listadapter2); <listview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/listview2" android:layout_centerhorizontal="true" />

if understand correctly, want load fragment's listview according tab's selected position.

if that's case, should not modify fragment's listview in activity. instead, pass tab's selected position fragment argument activity , load listview in fragment according position.

android-fragments android-listview

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -