2012-11-21 50 views
0

我有一個main.xml中的文件和文件cell_shape.xml。如何導入一個XML文件到另一個

在我main.xml中

我在cell_shape.XML有這個

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="wrap_content" 
android:layout_height="fill_parent" 
android:weightSum="100" > 

<include 
    android:id="tables" 
    layout="@layout/cell_shape" /> 

我有這個

<?xml version="1.0" encoding="utf-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/tables" 
    android:shape= "rectangle" > 
     <solid android:color="#000"/> 
     <stroke android:width="1dp" android:color="#ff9"/> 
</shape> 

我有這個錯誤

Exception raised during rendering: You must specify a valid layout 
reference. The layout ID @layout/cell_shape is not valid. Couldn't 
resolve resource @layout/cell_shape Exception details are logged in 
Window > Show View > Error Log 

,我不瞭解我如何正確導入,如果它我的main.xml

是否有教程介紹如何從一個xml文件導入不同的元素到另一個?

回答

0

嘗試刪除在includeid,所以它看起來就像這樣:

<include 
    layout="@layout/cell_shape" /> 

如果它不工作,嘗試用一個LinearLayout或其他類型的佈局封裝整個cell_shape。

順便說一句,爲Android設計的一致性,請使用顏色從this Android site

相關問題