2011-07-24 9 views
0

次のコードを使用してください。ListActivityでList以外のコンポーネントを使用することは可能ですか

BuyActivity.java

public class BuyActivity extends ListActivity { 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.transaction_list_view);   
     OrderAdapter orderAdapter = new OrderAdapter(this, 
      R.layout.custom_row_view, new ArrayList<Object>()); 
     setListAdapter(orderAdapter);   
     orderAdapter.add(new Object()); 
     orderAdapter.add(new Object());  
    } 
} 

transaction_list_view.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <ListView android:id="@id/android:list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="2" 
     android:drawSelectorOnTop="false"> 
    </ListView> 
    <TextView android:id="@id/android:empty" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="No data" 
    /> 
</LinearLayout> 

custom_row_view.xml

custom_row_view.xml

を参照してください

私は以下の結果を得ることができました。

enter image description here

は、リストのほかに、私はまた、ListActivityの下部に静的なラベルを持っていると思います。

私は

transaction_list_view.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <ListView android:id="@id/android:list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="2" 
     android:drawSelectorOnTop="false"> 
    </ListView> 
    <TextView android:id="@id/android:empty" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="No data" 
    /> 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="THIS IS TOTAL STATIC LABEL" 
    /> 
</LinearLayout> 

を試してみてくださいしかし、私は私の期待は

で何

enter image description here

を取得しています

私が逃したことはありますか?

答えて

2

あなたのListViewは、垂直方向にfill_parentとなっており、他のウィジェットのための空きがないことを示しました。あなたの体重は無視されています。代わりにandroid:layout_height0dipにすることをお勧めします。

0

静的テキストビューの高さをwrap_contentに設定してみてください。

0

相対レイアウトを試して、画面の下部に固定された静的ラベルを設定することもできます。それがあなたが意味するものでないなら、私はあなたをさらに助けようとします。幸運

関連する問題