我有一个 Android应用程序.在我从ListActivity派生的一个Activity中,我实现了OnItemLongClickListener.我想在ListItem已被LongClicked的相关列表项中启用删除按钮.我怎样才能做到这一点? OnItemLongClick
OnItemLongClickListener listener = new OnItemLongClickListener(){ public boolean onItemLongClick(AdapterView<?> av, View v, int position, long id) { Account a = null; a = (Account) av.getItemAtPosition(position); Toast.makeText(AccountActivity.this, "Long Clicked : " + a.getAccountName(), Toast.LENGTH_LONG).show(); //instead of the toast, I need to show/enable a button here... } }; getListView().setOnItemLongClickListener(listener);假设您在ListView的行布局中有一个Button,那么您可以将其显示为true`
OnItemLongClickListener listener = new OnItemLongClickListener(){ public boolean onItemLongClick(AdapterView<?> av, View v, int position, long id) { Account a = null; a = (Account) av.getItemAtPosition(position); v.findViewById(R.id.btnid).setVisiBility(View.VISIBLE); } };`