我正在处理列表,在此列表中 setOnItemLongClickListener 编写代码部分,用户长按打开对话框但对话框未打开?请发送任何打开对话框的建议?
listshipments.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener()
{
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id)
{
view.setSelected(true);
TextView tv = (TextView) view.findViewById(R.id.txtName);
String shipmenttxt = tv.getText().toString();
int b=delete_Message("Delete ", "Do you want delete shipment id", "Delete", "Cancel",shipmenttxt,position);
if(b==1){
this.mList.remove(position);
adapter.notifyDataSetChanged();
}
return true;
}
});
@SuppressWarnings("deprecation")
private int delete_Message(String sTitle,String sMessage,String sButton1_Text,String sButton2_Text,final String msg,final int position)
{
try {
alertDialog = new AlertDialog.Builder(getParent()).create();
alertDialog.setTitle(sTitle);
alertDialog.setIcon(R.drawable.info);
alertDialog.setMessage(sMessage);
alertDialog.setButton(sButton1_Text, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
aa=1;
delete(msg);
//new LoadDatashipment().execute();
return ;
} });
alertDialog.setButton2(sButton2_Text, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
aa=0;
//return;
}});
alertDialog.show();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return aa;
}