Sunday 15 April 2012

xml - Android SearchView issue: ListView not visible -



xml - Android SearchView issue: ListView not visible -

i have activitya extends actionbaractivity in android 4.4.2 (my project minsdkversion 14, maxsdkversion 20). in oncreate () method of activitya, start mymainfragment consumes whole content frame activitya owns. is, fragment started so:

fragment mymainfragment = new mymainfragment (); fragmentmanager fragmentmanager = getfragmentmanager (); fragmentmanager.begintransaction () .addtobackstack ("mymainfragment") .replace (r.id.post_login_content_frame, mymainfragment) .commit ();

i have searchview in activitya utilize in app. searchview workflow, capture query entered (successfully implemented), pass on fragment mymainfragment pulls info remote server , builds info custom adapter (all implementations successful). part have problem actual displaying of listview info search. specific problem view listview not shown. (i.e., view.isshown () == false in searchresultsfragment.oncreateview () sets adapter listview--see below).

i have custom base of operations adapter, searchresultsadapter extends baseadapter consumes arraylist<hashmap<string, string>> , presents in listview. know code there works because have used list in same project.

the mymainfragment object started after activitya starts (see above) fill r.id.post_login_content_frame view com.sonny.customview (see xml below), , puzzled why replaceing same searchresultsfragment won't create view.isshown () == true.

any help appreciated. have tried notifydatasetchanged ().

here xml files (activity_main.xml):

<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/post_login_drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- main content view --> <framelayout android:id="@+id/post_login_content_frame" android:layout_width="match_parent" android:layout_height="match_parent"> </framelayout> <textview android:id="@+id/status_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"/> <!-- navigation drawer --> <listview android:id="@+id/post_login_left_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:choicemode="singlechoice" android:divider="@android:color/transparent" android:dividerheight="0dp" android:background="#111"/> </android.support.v4.widget.drawerlayout>

fragment_main.xml:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <com.sonny.customview .... </com.sonny.customview> </relativelayout>

person_search_results.xml (the layout searchresultsfragment.java):

<listview android:layout_width="wrap_content" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/personsearchresultslv"> </listview>

and finally, actual list row content layout, single_search_result.xml:

<?xml version="1.0" encoding="utf-8"?> <tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <tablerow android:layout_width="fill_parent" android:layout_height="fill_parent"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:id="@+id/personsearchresultpersonnametextview" android:layout_column="0" android:layout_weight="1"/> </tablerow> <tablerow android:layout_width="fill_parent" android:layout_height="fill_parent"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancesmall" android:id="@+id/personsearchresultusernametextview" android:layout_column="0"/> </tablerow> </tablelayout>

android xml listview android-fragments

No comments:

Post a Comment