I have a problem now! I have custom ListView, there I have two TextView element. I want setVisibility(TextView.gone) for one TextView in ListView element. I don’t know how to do it
Write an example of how I can hide TextView ienter code heren all the items for ListView
ListView:
<ListView
android:id="@+id/listResultAvia"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:layout_weight="1"
android:background="#ffffff"
android:cacheColorHint="#ffffff"
android:drawingCacheQuality="auto" >
<!-- Preview: listitem=@layout/item -->
</ListView>
Custom item for ListVIew:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff" >
<TextView
android:id="@+id/textViewTimeResult"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
<TextView
android:id="@+id/textViewTimeResult2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"/>
</LinearLayout>
Show me how I can hide textViewTimeResult2 in the onCreate.
If I write:
TextView test = (TextView) findById(R.id.textViewTimeResult2);
test.setVisibility(TextView.GONE);
My program crashed in start.
ADD:
I use answer below, but now I get empty ListView. How do I fix this?
In your adapter you can try this code to hide the second textview.
ADDED:
you can add a boolean that toggles inside your
onClick()then modify thegetView();