我最近一直在試圖讓R.JAVA生成沒有用。我試過以下 1.添加空格清單文件 2.項目 - >清潔麻煩生成R.Java
所以我最後的猜測是,有我在XML文件中的一些錯誤I /月食一直沒能查看。所以我希望能有第二雙眼睛能夠檢查我的XML文件進行審查。只有三個,他們應該是非常基本的(我正在跟隨android書的介紹)。
清單文件
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.activites"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Activity2"
android:label="Activity 2" >
<intent-filter>
<action android:name="com.example.ACTIVITY2" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
Activity2.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is Activity 2!" />
</RelativeLayout>
再次感謝所有的你,已經採取超時您忙碌的白天/黑夜的幫助像我這樣的初學者。此外,如果有任何建議,而不是在xml中的錯誤,請隨時提出。
如這裏請求是存在的問題出現在Windows的>顯示視圖 - >問題
- R 1不能被解析爲一個可變
- R 1不能被解析爲一個可變
- R 1不能被解析到一個變量
標記不是那麼明顯,它用來在catlog中用下面幾行代碼顯示調試信息。
public class MainActivity extends Activity {
String tag =「Events」;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
Log.d(tag, "In the onCreate() event");
}
當您嘗試構建時,您在控制檯中是否收到錯誤/警告? – Geobits
在您的_Activity.xml_和_Activity2.xml_中,每個文件末尾都有一個 RelativeLayout>? –
@GabrielNetto他這樣做,它丟失了格式的帖子。 – Eric