公共类 MainActivity 扩展 Activity {
private Menu addMenuButton;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.mainact);
public void onPopup(View view)
{
PopupMenu menu=new PopupMenu(this,view);
menu.getMenuInflater().inflate(R.menu.menu1,menu.getMenu());
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener()
{
public boolean onMenuItemClick(MenuItem item)
{
Toast toast=Toast.makeText(MainActivity.this,
item.getTitle()+"Selected",Toast.LENGTH_SHORT);
//Intent intent2 = new Intent(MainActivity.this, YourSpotActivity.class);
//startActivity(intent2);
toast.show();
return true;
}
});
menu.show();
} }
单击项目列表时,请告诉解决方案进入另一个活动。我是编程新手。这是我的第一个程序。尝试深入解释。提前致谢。