c - How to make a Listview non selectable? -
i crated application using dialogbox. added listview it.
is there way make listview non-selectable?
the user should not select anything, should display data.
thanks in advance!
in order disable list items on list creation have subclass arrayadapter. have override following methods: isenabled(int position) , areallitemsenabled(). in former return true or false depending list item @ given position enabled or not. in latter return false.
if want use createfromresource() have implement method well, since arrayadapter.createfromresource() still instantiates arrayadapter instead of own adapter.
finally, code following:
class menuadapter extends arrayadapter<charsequence> { public menuadapter( context context, int textviewresid, charsequence[] strings) { super(context, textviewresid, strings); } public static menuadapter createfromresource( context context, int textarrayresid, int textviewresid) { resources resources = context.getresources(); charsequence[] strings = resources.gettextarray(textarrayresid); return new menuadapter(context, textviewresid, strings); } public boolean areallitemsenabled() { return false; } public boolean isenabled(int position) { // return false if position == position want disable } }
Comments
Post a Comment