簡體   English   中英

如何在 android 中動態地將按鈕放在 ExpandableListview 的末尾

[英]how to put a button at the end of ExpandableListview dynamically in android

在我的應用程序中,我有一個擴展 ExpandableListActivity 的活動,我想在 ExpandableListview 的末尾放置一個按鈕,這樣如果我擴展它應該在 listview 的末尾。

問題是在展開 Expandablelistview 中的所有項目后,它會全屏顯示並且按鈕不會出現。 如何使用 ExpandableListview 滾動按鈕? 我也試圖給 Scrollview 但它不起作用。 給我一個方法,我應該在 xml 文件中寫什么以獲得正確的 o/p。 謝謝

創建一個包含要設置為頁腳的Button的頁腳footerview layout ,然后嘗試

View footerView = ((LayoutInflater)ActivityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
ListView.addFooterView(footerView);

Footer_layout xml 文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingTop="7dip"
    android:paddingBottom="7dip"
    android:orientation="horizontal"
    android:gravity="center">
    <LinearLayout 
        android:id="@+id/footer_layout" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center"
        android:layout_gravity="center">

    <Button          
        android:id="@+id/footer_1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginRight="5dip">
    </Button> 

</LinearLayout>
 </LinearLayout> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM