2010-06-24 27 views
0

當我們設計一個視圖時,我有一些先決條件,正如你所看到的,我用視圖標籤打開了我的xml文件,它給了我錯誤。這是爲什麼?如果我將它更改爲LinearLayout比它的作品。View-tag dosen't work

<View xmlns:android="http://schemas.android.com/apk/res/android" 
class="android.app.SearchDialog$SearchBar" 
android:id="@+id/search_bar" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:focusable="true" 
android:descendantFocusability="afterDescendants"> 

<!-- Outer layout defines the entire search bar at the top of the screen --> 
<TextView 
    android:id="@+id/search_badge" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="2dip" 
    android:drawablePadding="0dip" 
    android:textAppearance="?android:attr/textAppearanceSmall" 
    android:textColor="?android:attr/textColorPrimaryInverse" /> 

<!-- Inner layout contains the app icon, button(s) and EditText --> 
<LinearLayout 

回答

0

我不認爲你可以在xml中創建這樣的視圖。 xml文件的目的是創建一個佈局,它將顯示在您的活動中。因此,頂層元素需要是其中一個佈局元素。見declaring layouts