私は私のmenu.xmlに次のコードを持っている:起動するウェブサイト
<item
android:id="@+id/more"
android:orderInCategory="100"
android:title="@string/goToWebsite"
app:showAsAction="ifRoom" />
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
case R.id.more:
goToUrl("http://www.example.com");
return true;
default:
return super.onOptionsItemSelected(item);
}
}
場合R.id.more
は実行されません。
goToUrl("http://www.example.com");
return true;
private void goToUrl (String url) {
Uri uriUrl = Uri.parse(url);
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
startActivity(launchBrowser);
}
間違っているのですか?
更新:r.id.more下
Toasingに動作していないaswelel:
case R.id.more:
Toast.makeText(this,"TEST", Toast.LENGTH_LONG).show();
が私の答え –
をチェック願って、あなたはすべてのエラーを得ていますか? –