嗨在我的eclipse android項目中,每當我嘗試添加一個名爲options.xml的xml文件時,R就會消失。 這就是我所做的, res文件夾下我通過eclipse添加選項創建了一個菜單文件夾。我創建了一個XML文件,名爲options.xml下,其內容是,eclipse android項目:R在添加菜單選項時消失
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Take Picture" android:id="@+id/camera" android:icon="@drawable/ic_menu_camera" android:showAsAction="ifRoom"></item>
</menu>
但每當我嘗試添加R.java從自動生成消失。我不明白。我關閉並重新開啓日食,嘗試新的項目沒有運氣。
我的佈局main.xml中,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="horizontal">
<SurfaceView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
如果我刪除r顯示在菜單文件夾。
你的佈局中有'android:id =「@ + id/camera」'元素嗎? – Sam 2012-04-19 00:18:54
我更新了我的問題。 – 2012-04-19 00:26:57
您要編程什麼API?如果您的應用程序專爲API 10,Android 2.3.4或更早版本設計,則禁止使用「showAsAction」。 – Sam 2012-04-19 00:33:49