regsCode1=objCommonServices.fetchRegisterationCode(etMobileNo.getText().toString().trim(),etPassword.getText().toString().trim());
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Recharhge Confirmation");
alert.setMessage("Message");
// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Editable value = input.getText();
System.out.println("Hello"+regsCode1 +" Value is "+value.toString());
if(value.toString().equals(regsCode1)){
System.out.println("Hello"+regsCode1+" "+value);
}
else{
System.out.println("B");
}
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});
alert.show();
結果 B が得られます。 System.out は両方の値を正しく出力しますが、2 つの文字列を比較しないため、Editable 値を String 値から変更し、オブジェクト クラスの toString fn を使用しました。しかし、2つの値を比較することもできません