我有这个问题。我有对话,我希望它解雇。它可以在Google Nexus上运行,但它并不适用于三星设备。请有人回答我!这是我的代码:
AlertDialog.Builder builder = new AlertDialog.Builder(Activity.this);
builder.setMessage("Insert number please");
builder.setCancelable(false);
final EditText numberInsert = new EditText(Activity.this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
numberInsert.setLayoutParams(lp);
builder.setView(numberInsert);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
final AlertDialog dialog = builder.create();
dialog.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(Integer.parseInt(numberInsert.getText().toString())<5){
Toast.makeText(Activity.this,"again please",Toast.LENGTH_LONG).show();
}
else{
dialog.dismiss();
}
}
});