Friday, August 27, 2010

[android-developers] How can I disable an item of ListView?

When I have a list view and there are 3 items which can choose by
user, I wanna show only choosable items to user because of some
reason. but I could not find any method in ListView or ArrayAdapter
class. Is there a solution?


protected void onCreate(Bundle savedInstanceState) {
......
menuList = new ArrayList<String>();
menuList.add(getResources().getText(R.string.apple).toString());
menuList.add(getResources().getText(R.string.banana).toString());
menuList.add(getResources().getText(R.string.grape).toString());

ArrayAdapter<String> adapter;
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, menuList);

ListView list = (ListView)findViewById(R.id.menuList);
list.setAdapter(adapter);
list.setOnItemClickListener(mItemClickListener);
....
}

for example, I wanna disable the second 'banana' item.
There are what I want exactly on the emulator, in sub menus of
Settings. and I looked at source of settings.
Almost settings menu are implemented with "PreferenceActivity"
It doesn't look like my code. In there, I found a method like below.
Preference btSettings = findPreference(KEY_BT_SETTINGS);
btSettings.setEnabled(false);

I think that's what I want. but Is there a solution based on my code?
rather than using PreferenceActivity.


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate