In my Android Application I have two Activities.
One is GmapsActivity and one is GmapsActivity1 and two layouts login.xml and main.xml
By default I want to load login.xml and then in this I want to call main.xml on different conditions of password. But when I call GmapsActivity1 application crashed. Here is my code sample for GmapsActivity
public class GMapsActivity extends MapActivity {
EditText password;
Button login;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
password=(EditText)findViewById(R.id.pass);
login=(Button)findViewById(R.id.logbtn);
login.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
Intent myIntent = null;
if(password.getText().toString().equals("admin")) {
myIntent = new Intent(getApplicationContext(), GMapsActivity.class);
startActivity(myIntent);
} else {
Toast.makeText(getBaseContext(), "invalid password - try again", Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
How could I solve this?
okay so you have
GMapsActivity.java with
login.xmland GmapsActivity1 withmain.xmlfirst of all change your manifeste like this
then your GMapsActivity.java should like this
and finally your GmapsActivity1.java should be like this
also you may like to check below simple tutorial to understand this
Start/Load Activity from Activity in Android
still have any doubt, let me know!!