public class HomeActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.homeactivity);
list(getIntent().getExtras().getString("JSON_Object"));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.items, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
switch(item.getItemId()){
case R.id.changepwd:
// Intent myIntent = new Intent(HomeActivity.this, Change_Password_Activity.class);
// this.startActivity(myIntent);
startActivity(new Intent("com.example.aishwarya.registerlogin.change_password_activity"));
Toast.makeText(this, "You selected change pwd", Toast.LENGTH_SHORT).show();
break;
case R.id.setuname:
Toast.makeText(getApplicationContext(), "You selected set username", Toast.LENGTH_SHORT).show();
break;
case R.id.setdp:
Toast.makeText(getApplicationContext(), "You selected set profile picture", Toast.LENGTH_SHORT).show();
break;
}
return true;
}
答案 0 :(得分:0)
您应该使用您评论过的代码:
Intent myIntent = new Intent(HomeActivity.this, Change_Password_Activity.class);
startActivity(myIntent);
确保您要隐式化的活动的名称具有名称" Change_Password_Activity "
答案 1 :(得分:0)
试试这个:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch(id){
case R.id.changepwd:
// Intent myIntent = new Intent(HomeActivity.this, Change_Password_Activity.class);
// this.startActivity(myIntent);
startActivity(new Intent("com.example.aishwarya.registerlogin.change_password_activity"));
Toast.makeText(this, "You selected change pwd", Toast.LENGTH_SHORT).show();
break;
case R.id.setuname:
Toast.makeText(getApplicationContext(), "You selected set username", Toast.LENGTH_SHORT).show();
break;
case R.id.setdp:
Toast.makeText(getApplicationContext(), "You selected set profile picture", Toast.LENGTH_SHORT).show();
break;
}
return true;
}