在我的android應用程序中,我創建了一個簡單的應用程序,在eclipse中通過file> project> Androiapp我已經放下了簡單的活動,但應用程序給出了錯誤。Android項目未加載,它產生不尋常的錯誤
佈局文件
<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"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
代碼文件
package com.example.testapp;
import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
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.activity_main, menu);
return true;
}
}
,我可以看到有這個代碼沒有錯誤,但在日食它仍然在setContentView(R.layout.activity_main);
和getMenuInflater().inflate(R.menu.activity_main, menu);
產生錯誤。
我覺得資源文件沒有加載
注意,在自動生成的代碼我還沒有作出任何改變。
同樣的想法,我認爲你的資源文件沒有加載... – 2013-02-24 06:33:06
你可以發佈你的堆棧跟蹤作爲logcat的一部分嗎? – lokoko 2013-02-24 06:47:24