我得到了一个自动完成文本视图,我想对列表项进行一次单击。我试图为actv设置一个onlongclick,但它的设置用于编辑文本,而不是列表项。
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;
}
});如何对下拉列表中的项目进行长时间单击?
发布于 2013-11-19 13:33:04
我认为最好的方法是有一个自定义适配器。
例如,可以扩展ArrayAdapter,在getView方法中,为适配器的每个视图调用setOnLongClickListener。
https://stackoverflow.com/questions/20072838
复制相似问题