android button点击事件不管用 求大神!!!
AlertDialog.BuildercustomDia=newAlertDialog.Builder(MainActivity.this);finalViewviewD...
AlertDialog.Builder customDia = new AlertDialog.Builder(
MainActivity.this);
final View viewDia = LayoutInflater.from(MainActivity.this)
.inflate(R.layout.updatecontact, null);
// customDia.setTitle("自定义对话框");
customDia.setView(viewDia);
final AlertDialog alertDialog = customDia.create();
final EditText username = (EditText) viewDia
.findViewById(R.id.username);
final EditText editTexttel = (EditText) viewDia
.findViewById(R.id.tel);
final EditText ID = (EditText) viewDia.findViewById(R.id.ID);
username.setText(text.toCharArray(), 0, text.length());
editTexttel.setText(teltext.toCharArray(), 0, teltext.length());
ID.setText(bdidtext.toCharArray(), 0, bdidtext.length());
final Button btn_delete = (Button) viewDia
.findViewById(R.id.deletecontact);
btn_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog dialog = new AlertDialog.Builder(MainActivity.this)
.setTitle("删除")
// 设置标题
.setMessage("是否要删除此联系人?")
// 设置提示消息
.setPositiveButton("确定",
new DialogInterface.OnClickListener() {// 设置确定的按键
@Override
public void onClick(
DialogInterface dialog,
int which) {
Interface.mySQLite.delete(
"contact", deleteid);
listItem.remove(childPosition);
alertDialog.dismiss();
updateContent();
}
})
.setNegativeButton("取消",
new DialogInterface.OnClickListener() {// 设置取消按键
@Override
public void onClick(
DialogInterface dialog,
int which) {
// do something
alertDialog.dismiss();
}
})
// .create();
.setCancelable(false)// 设置按返回键是否响应返回,这是是不响应
.show();// 显示
}
}); 展开
MainActivity.this);
final View viewDia = LayoutInflater.from(MainActivity.this)
.inflate(R.layout.updatecontact, null);
// customDia.setTitle("自定义对话框");
customDia.setView(viewDia);
final AlertDialog alertDialog = customDia.create();
final EditText username = (EditText) viewDia
.findViewById(R.id.username);
final EditText editTexttel = (EditText) viewDia
.findViewById(R.id.tel);
final EditText ID = (EditText) viewDia.findViewById(R.id.ID);
username.setText(text.toCharArray(), 0, text.length());
editTexttel.setText(teltext.toCharArray(), 0, teltext.length());
ID.setText(bdidtext.toCharArray(), 0, bdidtext.length());
final Button btn_delete = (Button) viewDia
.findViewById(R.id.deletecontact);
btn_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog dialog = new AlertDialog.Builder(MainActivity.this)
.setTitle("删除")
// 设置标题
.setMessage("是否要删除此联系人?")
// 设置提示消息
.setPositiveButton("确定",
new DialogInterface.OnClickListener() {// 设置确定的按键
@Override
public void onClick(
DialogInterface dialog,
int which) {
Interface.mySQLite.delete(
"contact", deleteid);
listItem.remove(childPosition);
alertDialog.dismiss();
updateContent();
}
})
.setNegativeButton("取消",
new DialogInterface.OnClickListener() {// 设置取消按键
@Override
public void onClick(
DialogInterface dialog,
int which) {
// do something
alertDialog.dismiss();
}
})
// .create();
.setCancelable(false)// 设置按返回键是否响应返回,这是是不响应
.show();// 显示
}
}); 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询