android下eclipse中This LinearLayout layout or its LinearLayout parent is possibly useless警告信息

eclipse提示:This LinearLayout layout or its LinearLayout parent is possibly useless黃色感嘆號警告信息

下面佈局代碼:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    
    <LinearLayout <!--此行有黃色感嘆號警告信息提示->
        android:id="@+id/listener"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:drawSelectorOnTop="false"
            android:scrollbars="vertical" >
        </ListView>

    </LinearLayout>
</LinearLayout>

警告原因:警告提示的意思是在這個佈局文件中父佈局控件(最外層的LinearLayout)沒有用;原因是在LinearLayout佈局當中嵌套了一個子的LinearLayout佈局,而在我的這個整個佈局文件中是一最外層的LinearLayout爲父控件進行整體佈局的,從而造成這段佈局代碼重複了LinearLayout佈局。

結局方法很簡單只需要重複的一個LinearLayout即可,正確代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:drawSelectorOnTop="false"
            android:scrollbars="vertical" >
        </ListView>
</LinearLayout>

這樣黃色的警告信息就會消失掉,機器人就能正常運行起來了。

發佈了21 篇原創文章 · 獲贊 3 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章