Hide Column In Listview Android
I had about 20 columns input into listview. But I want that user will have an option to disable (hide) some columns in view. I found that I can make my own Array Adapter and view f
Solution 1:
I found one way how to do it. For example I have this layout of item in listview. I will made my own adapter and then simply by calling setVisibility(View.GONE); i will hide this item from listview. PS: Here is only example in realcode there should be some IF() to hide column.
Layout for item.
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/description"
android:layout_alignBottom="@+id/description"
android:layout_toRightOf="@+id/description"
android:text="TextView" />
And MyAdapter.
privateclassConnectedAdapterextendsArrayAdapter<ConnectionClass> {
private ArrayList<ConnectionClass> connectionList;
publicConnectedAdapter(Context context, int textViewResourceId,
ArrayList<ConnectionClass> countryList) {
super(context, textViewResourceId, countryList);
this.connectionList = newArrayList<ConnectionClass>();
this.connectionList.addAll(countryList);
}
privateclassViewHolder {
TextView description;
TextView value;
}
@Overridepublic View getView(int position, View convertView, ViewGroup parent) {
ViewHolderholder=null;
Log.v("ConvertView", String.valueOf(position));
if (convertView == null) {
LayoutInflatervi= (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.activity_connected_item,
null);
holder = newViewHolder();
holder.description = (TextView) convertView
.findViewById(R.id.description);
holder.value = (TextView) convertView
.findViewById(R.id.value);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
ConnectionClassconnection= connectedList.get(position);
holder.description.setText(connection.getDescription());
holder.description.setVisibility(View.GONE);
holder.value.setText(connection.getValue());
return convertView;
}
}
Post a Comment for "Hide Column In Listview Android"