我不知道如何开始Intent
从我的ContextMenu
. 我有以下代码:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.profile);
Button button5 = (Button) findViewById(R.id.button5);
registerForContextMenu(button5);
//...code...//
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo){
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Profile Options");
menu.add(0,v.getId(),0, "Header");
menu.add(0,v.getId(),0, "Header");
**This is where my Intent is ** Intent intent = new Intent (CustomizeActivity2.this, CustomizeActivity.class);
startActivity(intent);
public boolean OnContextItemSelected(MenuItem item) {
if(item.getTitle()=="Edite Profile"){
function1(item.getItemId());
}
else {return false;}
return true;
}
public void function1(int id){
Toast.makeText(this,"Edit Profile Called", Toast.LENGTH_SHORT).show();
}
当我单击我的项目时,我想开始另一个活动ContextMenu
,我有一些设置。