我正在尝试学习如何在android中使用菜单我刚刚在menu.xml文件中添加了几个子项。并运行它。在控制台中一切看起来都很正常但是当我检查logcat时会出现很多错误。我不知道出了什么问题我无法通过我5天的android编程表达来解决这个问题。请你帮忙。谢谢提前
02-15 05:13:04.420: E/logwrapper(912): executing /system/bin/e2fsck failed: No such file or directory
02-15 05:13:04.440: E/logwrapper(915): executing /system/bin/e2fsck failed: No such file or directory
02-15 05:13:05.010: E/SurfaceFlinger(923): hwcomposer module not found
02-15 05:13:05.820: E/SurfaceFlinger(923): ro.sf.lcd_density must be defined as a build property
02-15 05:13:08.240: E/logwrapper(1175): executing /system/bin/ip failed: No such file or directory
02-15 05:13:08.240: E/logwrapper(1176): executing /system/bin/ip failed: No such file or directory
02-15 05:13:19.410: E/FlpHardwareProvider(1251): Error hw_get_module 'flp': -2
02-15 05:13:19.410: E/FlpHardwareProvider(1251): Error hw_get_module 'flp': -2
02-15 05:13:19.410: E/LocationManagerService(1251): no geocoder provider found
02-15 05:13:19.410: E/LocationManagerService(1251): No FusedProvider found.
02-15 05:13:19.410: E/LocationManagerService(1251): no geofence provider found
02-15 05:13:25.100: E/Netd(920): exec() res=0, status=256 for /system/bin/iptables -t mangle -A st_mangle_EXEMPT -d 10.0.2.4/32 -j MARK --set-mark 1
02-15 05:13:25.100: E/logwrapper(1561): executing /system/bin/ip failed: No such file or directory
02-15 05:13:25.100: E/logwrapper(1562): executing /system/bin/ip failed: No such file or directory
02-15 05:13:25.100: E/SecondaryTablController(920): ip route add failed: /system/bin/ip route add 10.0.2.2/32 via 0.0.0.0 dev eth0 table 60
02-15 05:13:25.100: E/ConnectivityService(1251): Exception trying to add a route: java.lang.IllegalStateException: command '16 interface fwmark exempt add 10.0.2.2/32' failed with '400 16 Failed to add exemption rule (File exists)'
02-15 05:13:37.460: E/StrictMode(1693): at com.android.mms.transaction.TransactionService.onNewIntent(TransactionService.java:224)
02-15 05:13:37.460: E/StrictMode(1693): at com.android.mms.transaction.TransactionService$ServiceHandler.handleMessage(TransactionService.java:621)
02-15 05:13:37.460: E/StrictMode(1693): at android.os.Looper.loop(Looper.java:137)
02-15 05:13:37.460: E/StrictMode(1693): at android.os.HandlerThread.run(HandlerThread.java:61)
: E/(): Device disconnected
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
这是我的其余代码
</menu>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">mymenu</string>
<string name="action_settings">Settings</string>
<string name="MenuItem">Open</string>
<string />
</resources>
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
答案 0 :(得分:1)
onCreateOptionsMenu(Menu menu)
。并在那里夸大了适当的菜单。onOptionsItemSelected(MenuItem item)
并检查相应的MenuItem ID。