문제

I got an autocompletetextview and i want to make an onlongclick for the list items. i tried to set an onlongclick for the actv but its set for the edittext not for the list items.

     ArrayAdapter<String> adapter = new ArrayAdapter<String>
      (this, android.R.layout.simple_list_item_1, masini);
      txtNrInmat.setAdapter(adapter);
      txtNrInmat.setLongClickable(true);

      txtNrInmat.setOnLongClickListener(new OnLongClickListener() { 
          public boolean onLongClick(View v) {
              Toast.makeText(getApplicationContext(), "Long Press works", Toast.LENGTH_SHORT).show();
              return true;
          }
      });

How can i make an onlongclick for the items inside the dropdown list?

도움이 되었습니까?

해결책

The best way to do it I think would be to have a custom adapter.

You can for exemple extend ArrayAdapter, and in getView method, call setOnLongClickListener for each view of your adapter.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top