2012-12-08 48 views
3

我正在爲Java Eclipse上的Android開發一些應用程序。至於現在一切正常,但今天突然佈局圖形顯示停止工作,無論我嘗試創建新佈局還是嘗試打開現有佈局。它顯示沒有XML內容。請爲您的文檔添加根視圖或佈局。錯誤。我試圖按照android sdk main.out.xml parsing error?的說明操作,但我沒有XSL選項 Eclipse - > Window - > Preferences - > Run/Debug - > Launch - > Lauch Configuration - > Filter檢查啓動配置類型。我也沒有任何.out.xml文件。Java Eclipse android-XML編輯器(圖形顯示)不起作用

這是我的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=".FirstScreenActivity" /> 

</RelativeLayout> 

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="s.manipulator" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="14" 
     android:targetSdkVersion="15" /> 

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".FirstScreenActivity" 
      android:label="@string/title_activity_first_screen" > 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value="android.app.LauncherActivity" /> 
     </activity> 
     <activity 
      android:name=".MainMenuActivity" 
      android:label="@string/title_activity_main_menu" > 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value="s.manipulator.FirstScreenActivity" /> 
     </activity> 
    </application> 

</manifest> 

回答

4

簡單的解決辦法:

右鍵單擊佈局文件 - >打開方式 - > Android的佈局編輯器

在Eclipse中,去窗口 - >首選項 - >常規 - >編輯 - >文件關聯並選擇* .xml,然後在關聯編輯器列表中的Android佈局編輯器條目上按默認。

+0

不幸的是,沒有效果。就好像這個佈局編輯器中的圖形顯示器工作不正常(在原始XML代碼中存在實際內容時它沒有顯示出競爭)。 經過一些進一步的研究[這裏](http://stackoverflow.com/questions/5050443/android-development-missing-theme-error-in-eclipse-ide-for-layout-xml-files)和[這裏]( http://stackoverflow.com/questions/7992036/graphical-layout-missing-for-layout-xml-files),我結束了重新安裝ADT插件,它解決了這個問題,但它仍然是一種糟糕的解決方案。 .. –

0

我不得不最終做的是從kumar_android所指的列表中選擇Legacy Android Xml Resources Editor並將其設置爲默認值。我必須從點擊添加按鈕時出現的列表中選擇它。之後,我重新開始日食,一切都很好。