fragment
在我的活动中使用,我想显示一个dialogue
On ItemLongClickListener
of viewlist
。我尝试了一些代码,但是失败了。反正有做吗?
code
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> arg0, View v,int index, long arg3) {
Toast.makeText(getActivity(),"thul thuk!",Toast.LENGTH_SHORT).show();
//show-dialogue here
return false;
}
});
试试这个..
custom_dialog.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</LinearLayout>
爪哇
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> arg0, View v,int index, long arg3) {
Toast.makeText(getActivity(),"thul thuk!",Toast.LENGTH_SHORT).show();
Dialog dialog = new Dialog(getActivity());
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Custom Dialog");
dialog.show();
return false;
}
});
编辑
您可以使用上下文菜单
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句