Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide a textview in SimpleAdapter

am using a simple adapter to show set of strings in different text fields in a listview... i want when i click a particular content in that listview, some textview should be invisible.. how to do that...

my code is

String[] from = new String[] {"ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN"};

int[] to = new int[] { R.id.textView_1, R.id.textView_2, R.id.textView_3, R.id.textView_4, R.id.textView_5, R.id.textView_6, R.id.textView_7};


Adapter adapter = new SimpleAdapter(this, Maps, R.layout.search, from, to);
ListView lvSearch = (ListView) findViewById(R.id.listView_SearchResult);
lvSearchResult.setAdapter(adapter);

here on click

R.id.textView_5, R.id.textView_6, R.id.textView_7

should be invisible

like image 318
786 Avatar asked Dec 07 '22 10:12

786


2 Answers

Not sure what exactly you're looking for here, but if what you're trying to do is simply hide the TextView, you could do the following:

TextView txtView = (TextView)findViewById(R.id.textView_6);
txtView.setVisibility(View.GONE)

We can try and help you further if you provide us with a bit more information.

like image 73
Marcos Placona Avatar answered Dec 23 '22 14:12

Marcos Placona


Set the attribute android:visibility="gone" for the TextViews R.id.textView_5, R.id.textView_6, R.id.textView_7 in the layout layout.search

For your example I guess the result should look like:

<TextView android:id="@+id/textView_5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="hidden"
        android:visibility="gone"/>
like image 21
Alexander Egger Avatar answered Dec 23 '22 16:12

Alexander Egger