How to disable items in a List View?

I have a list view which is populated via records from the database. Now i have to make some records visible but unavailable for selection, how can i achieve that?

here’s my code

public class SomeClass extends ListActivity { 
    private static List<String> products; 
    private DataHelper dh; 
    public void onCreate(Bundle savedInstanceState) { 
        dh = new DataHelper(this); 
        products = dh.GetMyProducts();  /* Returns a List<String>*/ 
        super.onCreate(savedInstanceState); 
        setListAdapter(new ArrayAdapter<String>(this, R.layout.myproducts, products)); 
        ListView lv = getListView();
        lv.setTextFilterEnabled(true); 
        lv.setOnItemClickListener( new OnItemClickListener() { 
            @Override 
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { 
                // TODO Auto-generated method stub 
                Toast.makeText(getApplicationContext(), ((TextView) arg1).getText(), Toast.LENGTH_SHORT).show(); 
            } 
        }); 
    } 
}

The layout file myproducts.xml is as follows:

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:padding="10dp" 
    android:textSize="16sp"> 
</TextView>

How can I disable the OnItemClick() in a List of items in Android?

How can I disable the OnItemClick() once a List item has been clicked? I am trying to display a list of items in a grid view. Once the user clicks on one item, it must not be possible for him to click

disable list items in ListView

I wanna disable all list items in a ListView excluding the 1st position item. That means every time the 1st item can be clicked not the all. How can I do this. Is there any way. Give me some sample co

Android: How to disable list items on list creation

I’m pretty new to Android dev and still working out a lot of things. I’ve got a main menu showing using the following code, but can’t work out how to disable selected items in the menu. Can anybody he

How to disable indentation of LaTeX list items? [closed]

By default the enumerate environment is indented with respect to the current environment. How can I disable this indentation so that an enumerate environment of three items would produce the same ou

how to check the list view items when we are using groups in list view

how to check the list view items when we are using list view group s… I have list view in that i am using two groups …. If i click on the list view first group item then click on the list view sec

In List view how many list items can load in android

Normally in ListView are used in android,but how many items can totally load in list view ? Is it possible to load more than 10,000 items ?

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-

disabling and greying out list items

I have a list view. In that list view, I have to grey out and disable some items, and enable the rest list items with seperate color. How to do this?

How to disable onitem click in list view paricular row in android

How to disable list view on item click in particular row in android.if value is search i have to disable the onitem click event of particular row in list view in android can anybody tell how to do? Th

Disabling items in the list view

I have a requirement wherein I want to disable items in the list view. Say e.g., I have 5 items in the listview out of which I want to only enable 1 item. Note: disabling means greying out the item. F

Answers

Make your own subclass of ArrayAdapter that has AreAllItemsEnabled() return false, and define isEnabled(int position) to return true/false for a given item in your data set.