@OverrIDe public boolean onoptionsItemSelected(MenuItem item) { switch (item.getItemID()) { case R.ID.icon: Intent intent = new Intent(this,Main.class); startActivity(intent); case R.ID.help: //popup window code here } return true; }}
我最简单的方法吗?谢谢!
解决方法@OverrIDepublic boolean onoptionsItemSelected(MenuItem item) { switch (item.getItemID()) { case R.ID.icon: Intent intent = new Intent(this,Main.class); startActivity(intent); case R.ID.help: //popup window code hereToast.makeText(this,"This is the Toast message",Toast.LENGTH_LONG).show(); } return true;}}
或者我可以使用对话框
@OverrIDepublic boolean onoptionsItemSelected(MenuItem item) { switch (item.getItemID()) { case R.ID.icon: Intent intent = new Intent(this,Main.class); startActivity(intent); case R.ID.help: //popup window code here AlertDialog.Builder alertBox = new AlertDialog.Builder(this); // set the message to display alertBox.setMessage("This is the alertBox!"); // add a neutral button to the alert Box and assign a click Listener alertBox.setNeutralbutton("Ok",new DialogInterface.OnClickListener() { // click Listener on the alert Box public voID onClick(DialogInterface arg0,int arg1) { // the button was clicked } }); // show it alertBox.show(); } return true;}
}
总结以上是内存溢出为你收集整理的Android – 从选项菜单中d出文本对话框全部内容,希望文章能够帮你解决Android – 从选项菜单中d出文本对话框所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)