Dee*_*pzz 3 android listview button long-press
我需要在长按列表项时显示删除按钮.
我有长按的代码..但不知道如何编码在这个长按内显示一个按钮...
终于得到了答案......
.xml文件
<ImageButton
android:id="@+id/imgdelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/delete"
android:visibility="invisible"/>
Run Code Online (Sandbox Code Playgroud)
.java文件
lv.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
arg1.findViewById(R.id.imgdelete).setVisibility(View.VISIBLE);
return false;
}
});
}
Run Code Online (Sandbox Code Playgroud)