2012-08-04 61 views
0

如何檢測佈局錯誤?如果我啓動日食並打開佈局的第一個活動。但第一Activity.java文件給出了一些錯誤中的setContentView(R.layout.main).AM使用最新的SDK API 16如何檢測佈局錯誤?

package com.eConnect.Restaurant; 

import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu; 

public class LoginActivity extends Activity { 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
    getMenuInflater().inflate(R.menu.main, menu); 
    return true; 
    } 
} 

的main.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#000000" 
    android:orientation="vertical" > 

    <ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="15dip" 
    android:contentDescription="@string/desc" 
    android:src="@drawable/econnect_logo" /> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="15dip" 
    android:text="@string/uid" 
    android:textAppearance="?android:attr/textAppearanceLarge" /> 

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="15dip" 
    android:background="#ffffff" 
    android:hint="@string/uid" 
    android:inputType="number" 
    android:textColor="#9966cc" > 

    <requestFocus /> 
</EditText> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="15dip" 
    android:text="@string/PW" 
    android:textAppearance="?android:attr/textAppearanceLarge" /> 

<EditText 
    android:id="@+id/editText2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="15dip" 
    android:background="#ffffff" 
    android:hint="@string/PW" 
    android:inputType="numberPassword" 
    android:textColor="#9966cc" /> 

<TextView 
    android:id="@+id/textView3" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="15dip" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:textColor="#ff0000" 
    android:textStyle="bold" /> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="15dip" 
    android:background="#cccccc" 
    android:text="@string/bt" 
    android:textColor="#006600" 
    android:textStyle="bold" /> 

的AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.eConnect.Restaurant" 
    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" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name=".LoginActivity" 
     android:label="@string/title_activity_login" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    </application> 

</manifest> 
+2

什麼錯誤?請發佈logcat輸出! – 2012-08-04 06:11:44

+0

只需構建一次您的項目。 – user1387035 2012-08-04 06:20:20

+0

akshay如何在eclipse中避免android emulater中的物理鍵盤 – USER5762 2012-08-06 04:47:49

回答

1

首先清理你的項目。通過使用Project> Clean.你必須做的另一件事是從列表中刪除R.Java.Again清理項目。試試這個,讓我知道。

+0

我們的R.java文件在刪除和清理完畢後不顯示我的郵箱 – USER5762 2012-08-04 06:52:42

+0

@CharuPriya您在xml文件或logcat或控制檯中遇到什麼錯誤? – Akshay 2012-08-04 06:57:15

+0

@CharuPriya你解決了你的問題嗎? – Akshay 2012-08-04 08:33:35

0

生成項目once.I也面臨這樣的,但是當我建立我的項目的錯誤消失

+0

如何構建pjt – USER5762 2012-08-04 06:24:24

+0

在您的eclipse環境中,您可以看到諸如文件,編輯,運行等選項。同樣,在選擇構建項目時也有選項Build。 – user1387035 2012-08-04 06:25:40

+0

讓我知道你建立你的項目後的狀態 – user1387035 2012-08-04 06:30:07