I am trying to update a single row (two textviews) in a listview by changing the visibility of the second textview from "gone" to "visible".
Here is the XML for the custom layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/userlistlayout"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#000000"/>
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" android:visibility="gone"/>
I am using an arrayadapter to bind the data from a string[] to the listview. This is working perfectly. Where I am running into problems is pushing the change back to the screen.
Here is the test code I have for my array adapter and the attempt to set the visiblity on a single row's second textview.
searchResults = (ListView) findViewById(R.id.listView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.userlist, R.id.textView1,names);
searchResults.setAdapter(adapter);
//all the code above this point works perfectly to populate the listview (textview1)
with the names passed in from the names string[]
LinearLayout hold = (LinearLayout) adapter.getView(2, null, null);
TextView hold2 = (TextView) hold.findViewById(R.id.textView2);
hold2.setVisibility(TextView.VISIBLE);
adapter.notifyDataSetChanged();
searchResults.invalidateViews();
This code does not throw any kind of error, however, i am not getting any kind of update on the listview. I am not sure what I am doing wrong or what step I am missing to get the visibility change made to hold2 to be pushed back into the adapter/listview and updated on the screen whereby the second textview on that particular row will be visible.
Once I get this working I want to trigger it onclick.
Any help would be much appreciated.