我是Android編程的新手,並且即將運行Android應用程序。 我得到了R.layout無法解析爲變量錯誤。當我導入com.package.r;並刪除了android.r它沒有做任何事情。在清理項目後錯誤消失了,但是它在r.layout.activity_main上發生了錯誤(轉換爲activity_list ...)。該代碼片段已附加。在R類型中創建字段佈局/ main - 無法解析
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Menu;
import com.procedure.culture.R;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
@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);`
我已重新啓動eclipse並清理了一百萬次項目,但徒勞無功。 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="#A1F5F8" >
<!--
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title"
android:textColor="#000000"
android:textSize="30dp"
/>
-->
您關閉了標記嗎? –
Robert
2014-08-28 11:58:30
是@Robert,多數民衆贊成在關閉! – CSA 2014-08-28 12:02:59
檢查:http://www.tutorialspoint.com/android/android_hello_world_example.htm – 2014-08-28 12:03:40