Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hidden Field in ListView Android?

Tags:

android

I'm wondering if there is a way to hide a field in Android.
I tried with setting the value in a TextEdit and then making the TextEdit invisible, but the result is that the value is invisible, but the control takes space.

In my case, I want to store an extra value in a row of a ListView.
Is there another solution besides using hidden fields?

like image 848
user449689 Avatar asked Sep 17 '10 15:09

user449689


2 Answers

Use View's public static final int GONE field.

In your case textEdit.setVisibility(View.GONE), or in xml android:visibility="gone"

Setting the view to INVISIBLE does not take layout into consideration, but GONE does.

like image 124
McStretch Avatar answered Sep 27 '22 19:09

McStretch


View has methods setTag() and getTag() that you can use to associate some extra data with row of ListView. For example I'm using CursorAdapter class and in newView() and bindView() methods I call view.setTag(). Then in OnItemClickListener I call view.getTag().

like image 39
lopek Avatar answered Sep 27 '22 19:09

lopek