2011-07-05 22 views
1

我在ScrollView中嵌入了一個TableLayout,因此它可以滾動。它是建立像這樣(沒有什麼特別的地方):如果可滾動的TableLayout是空的,則顯示一條消息

<ScrollView android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@id/rejectDataTypeButton" 
    android:layout_above="@id/datalist_nextButton" > 

    <TableLayout android:id="@+id/dataListTable" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:stretchColumns="1" /> 

</ScrollView> 

我如何使它顯示一條消息,如果是空的,類似的方式ListActivity不是嗎?這是甚至可能的,因爲TableLayout沒有像ListView那樣的.setEmptyView(View)方法?

回答

0

然而,你可以用Java來做到這一點,如果你的數組/結果/任何東西都是空的,你會添加一個新的TableRow與您的信息消息。

想要做到這一點的最好的地方(測試數據集是否爲空並顯示信息)在onStart-方法中。

相關問題