我厌倦了一些代码,但我无法修复它。我的manu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_feedback"
app:showAsAction="never" />
我如何在这个xml中获得一个weblink?非常感谢。
答案 0 :(得分:0)
ContextMenu的示例
首先覆盖onCreateContextMenu:
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(/*your menu id*/, menu);
}
然后覆盖onContextItemSelected,打开webview或Play商店应用程序:
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId()){
case action_settings: {
//your code
return true;
}
default:
return super.onContextItemSelected(item);
}
}