我正在尝试从 EditText 中拉出一条线并与图钉进行比较。如果是正确的密码,则显示授权,否则显示错误密码。我不能让 1234 等于 1234 - 它总是说 Pin Invalid。
Context context = this;
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Pin Entry");
final EditText pinEntry = (EditText) dialog.findViewById(R.id.pinAuth);
Button dialogButton = (Button) dialog.findViewById(R.id.dialogButton);
dialogButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
CharSequence alertText;
int duration = Toast.LENGTH_SHORT;
CharSequence pint = pinEntry.getText();
if(pint != "1234")
{
alertText = "Pin invalid.\nPlease try again.";
Toast toast = Toast.makeText(context, alertText, duration);
toast.show();
updateList();
}
else if(pint == "1234")
{
alertText = "Pin authorized";
Toast toast = Toast.makeText(context, alertText, duration);
toast.show();
}
dialog.dismiss();
}
});
dialog.show();
}