0

I want to disable the response to click and long click on items for a listview in android. I have set isEnabled(int position) of the adapter to return false, so that the cells in the listview does not response to click operation, but they still respond to long click operations(that is, they are highlighted when long clicked). the question is, what can I do to make the cells not highlighted when they are long clicked. Thank you.

Eden
  • 1
  • 2
  • you can have blank implementation of the onClick and LongClick ,Try it then tell me it help you or not – UnderGround May 13 '13 at 03:48
  • Try ListView.setOnClickListener(null) and ListView.setOnLongClickListener(null). And if you have any ListView.setOnCreateContextMenuListener(Context), remove it. – Chor Wai Chun May 13 '13 at 04:06

3 Answers3

1

Try setClickable instead of setEnabled

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
1
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    if (((AdapterContextMenuInfo)menuInfo).position == 1) {
        inflater.inflate(R.menu.foo1, menu);
        return;
    }
    inflater.inflate(R.menu.foo2, menu);
}        
enadun
  • 3,107
  • 3
  • 31
  • 34
0

Set any background for your list item main layout.

Sudheesh B Nair
  • 11,023
  • 1
  • 16
  • 13