Arash GM
Arash GM

Reputation: 10395

OnItemClickListener With OnItemLongClickListener

how can i use both OnItemClickListener and OnItemLongClickListener or just disable longclick on a list view? i've override OnItemLongClickListener and when i return true on onItemLongClick the longclick will disable but OnItemClickListener wont respond anymore.

DailyReportList.setOnItemLongClickListener(new OnItemLongClickListener(){ 
        @Override   
    public boolean onItemLongClick(AdapterView parentView, View childView, int position, long id) {

        return true;}});


    registerForContextMenu(DailyReportList);
    DailyReportList.setOnItemClickListener(new OnItemClickListener(){
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            arg1.showContextMenu();
            FillTxtWithListItems(arg1);

        }});

Upvotes: 0

Views: 1582

Answers (2)

Lalith B
Lalith B

Reputation: 12239

If you want to disable onClick or onLongClick you just need to uncheck/check the feature in your layout xml properties. Find the image on how it can be disabled..enter image description here

enter image description here

Upvotes: 2

Marcin Orlowski
Marcin Orlowski

Reputation: 75629

If you do not want long click listener nor context menu just do not set any and do not call registerForContextMenu(). Lists do not have these by themselves.

Upvotes: 1

Related Questions