Use both onClickListener and onLongClickListener in listview Android 1.6

后端 未结 4 950
灰色年华
灰色年华 2020-12-29 03:03

I am using both onClickListener and onLongClickListener for a TextView in a ListView. I see that in Android 1.6,

相关标签:
4条回答
  • 2020-12-29 03:40

    I think you you should use OnItemLongClickListener() instead of OnLongClickListener().

    See developers website for further response

    0 讨论(0)
  • 2020-12-29 03:43

    Did you return boolean true at the end of OnLongClickListener to indicate you don't want further processing?

    0 讨论(0)
  • 2020-12-29 03:43
    TextView t1 = (TextView) findViewById(R.id.textView1);
    t1.isClickable();
    
    t1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Toast.makeText(getBaseContext(), "Clicked", Toast.LENGTH_SHORT).show();
        }
    });
    
    t1.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            // TODO Auto-generated method stub
            Toast.makeText(getBaseContext(), "Long Clicked", Toast.LENGTH_SHORT).show();
            return true;
        }
    });
    
    0 讨论(0)
  • 2020-12-29 04:02
    itemToClick.setOnClickListener(new View.OnClickListener() {
       @Override
        public void onClick(View v)      { 
          //do your logic on click 
         });
    itemToClick.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
          // do your logic for long click and remember to return it 
            return true; }});
    
    0 讨论(0)
提交回复
热议问题