我想在android中做這樣的事情。我的意思是,我有密碼的文本框,我試圖使人們看到一個文本視圖,如果密碼是正確的,但我還是不斷呈現出異常java.lang.nullpointerexception
這裏是我的代碼android java.lang.nullpointerexception
public class MainActivity extends Activity {
EditText Password;
Button login;
TextView txtDash;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Password=(EditText)findViewById(R.id.pass);
login=(Button)findViewById(R.id.login);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View V) {
try {
if (Password.getText().toString().equals("dsml"))
{
txtDash.setVisibility(View.VISIBLE);
login.setVisibility(View.INVISIBLE);
Password.setVisibility(View.INVISIBLE);
}
else
{
Toast.makeText(getBaseContext(), "invalid password - try again", Toast.LENGTH_SHORT).show();
}
}catch(Exception e){
//Log.e("log_tag", "Error"+e.toString());
Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
請任何一個幫助getout這
我已經對不起 – user1820339