代码如下,这样获取edittext.gettext().tostring()值总为空,该怎么改呢?
final View viewDialog=(View)getLayoutInflater().inflate(R.layout.ad_dialog,null);
new AlertDialog.Builder(Ad_Delete.this).setTitle("请输入删除数量(不能大于现有本数)")
.setView(getLayoutInflater().inflate(R.layout.ad_dialog, null))
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
EditText ad_delete_edit = (EditText)viewDialog.findViewById(R.id.ad_delete_number);
int deleteNumber = Integer.parseInt(ad_delete_edit.getText().toString());
if (deleteNumber > nowNumber || deleteNumber < 0) {
Toast.makeText(Ad_Delete.this, "输入数量有误,请输入不大于现有数量的数目", Toast.LENGTH_LONG).show();
} else {
sqLiteOpenHelper_ad.getReadableDatabase().execSQL("updata Administrator_inf set book_totalnumber = ?, " +
"book_nownumber = ? where _id = ?",
new Integer[]{totalNumber - deleteNumber, nowNumber - deleteNumber, id});
Toast.makeText(Ad_Delete.this, "删除成功!", Toast.LENGTH_LONG).show();
}
}
}).show();
}
});
final View viewDialog=(View)getLayoutInflater().inflate(R.layout.ad_dialog,null);
new AlertDialog.Builder(Ad_Delete.this).setTitle("请输入删除数量(不能大于现有本数)")
.setView(getLayoutInflater().inflate(R.layout.ad_dialog, null))
改成
final View viewDialog=(View)getLayoutInflater().inflate(R.layout.ad_dialog,null);
new AlertDialog.Builder(Ad_Delete.this).setTitle("请输入删除数量(不能大于现有本数)")
.setView(viewDialog)
不然你获取edittext的viewDialog不是dialog显示的viewDialog
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。