按下菜单项时如何打开自定义布局
how to open a custom layout when menu item is pressed
我创建了一个布局文件,需要在按下菜单项时显示。
public boolean onOptionItemSelected(MenuItem item){
switch (item.getItemId()) {
....
case R.id.help:
return true;
......
}
}
帮助项目菜单应显示 layout.xml 文件。
您可以在新的 Activity
中使用布局。您可以使用 Intent
调用这个新的 Activity
,
Intent intent = new Intent(CurrentActivity.this, YourNewActivity.class);
startActivity(intent);
或者您可以编写自定义对话框来扩充布局,
How to create a Custom Dialog box in android?
我创建了一个布局文件,需要在按下菜单项时显示。
public boolean onOptionItemSelected(MenuItem item){
switch (item.getItemId()) {
....
case R.id.help:
return true;
......
}
}
帮助项目菜单应显示 layout.xml 文件。
您可以在新的 Activity
中使用布局。您可以使用 Intent
调用这个新的 Activity
,
Intent intent = new Intent(CurrentActivity.this, YourNewActivity.class);
startActivity(intent);
或者您可以编写自定义对话框来扩充布局,
How to create a Custom Dialog box in android?