我有使用图标成功打开的选项菜单,但是,当我单击它时,它什么也不做,而且 LogCat 和错误日志中也没有任何内容。这是我的主要活动和电子邮件活动。我有所有按钮email.xml
和一个项目gameoptions.xml
。请帮忙。
private ListView lv1;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.gameoptions, menu);
menu.findItem(R.id.btn_market);
return true;}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.btn_market:
startActivity(new Intent(getApplicationContext(),EmailActivity.class));
return true;
default:
return super.onOptionsItemSelected(item);
}
}
电子邮件活动:
public class EmailActivity extends Activity {
Button send;
EditText address, subject, emailtext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.email);
Button b=(Button)this.findViewById(R.id.btn_market);
b.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
Uri address=Uri.parse("https://play.google.com/store/apps/details?id=ru.kenzhekul.tashiev&hl=ru");
Intent surf=new Intent(Intent.ACTION_VIEW, address);
startActivity(surf);
}
});
send = (Button) findViewById(R.id.emailsendbutton);
address = (EditText) findViewById(R.id.emailaddress);
//subject = (EditText) findViewById(R.id.emailsubject);
emailtext = (EditText) findViewById(R.id.emailtext);
send.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { address.getText().toString() });
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,emailtext.getText().toString());
EmailActivity.this.startActivity(Intent.createChooser(emailIntent, "Отправка письма"));
}
});
}
}