Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the particular list item in list-view in android?

How to disable the particular list item in list-view in android? I mean if once i selected any one of item from a list-view,that item suppose to be disabled which means that item should not be select-able again. How to do this?

Suggestions please

Thanks for your precious time!..

like image 397
prabu Avatar asked Jul 29 '13 08:07

prabu


People also ask

How do I remove items from list view?

To remove items programmaticallyUse the RemoveAt or Clear method of the Items property. The RemoveAt method removes a single item; the Clear method removes all items from the list.

How do I edit list view in android?

OnItemClickListener MshowforItem = new AdapterView. OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((TextView)view). setText("Hello"); } };

How is it possible to view a list in Android?

Android ListView is a view which groups several items and display them in vertical scrollable list. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database.


1 Answers

try using this code in setOnItemClicklistener()

if(listview.getChildAt(selectedPosition).isEnabled())
{
    listview.getChildAt(selectedPosition).setEnabled(false);
}
like image 154
Vedang Jadhav Avatar answered Sep 24 '22 09:09

Vedang Jadhav