如何在android中动态地在ExpandableListview的末尾放置一个按钮

发布于 2024-11-18 10:37:02 字数 261 浏览 6 评论 0原文

在我的应用程序中,我有一个扩展 ExpandableListActivity 的活动,我想在 ExpandableListview 的末尾放置一个按钮,这样如果我扩展它应该在 listview 的末尾。

问题是展开 Expandablelistview 中的所有项目后,它会全屏显示并且按钮不会出现。 如何使用 ExpandableListview 滚动按钮? 我也尝试给 Scrollview 但它不起作用。 给我一个方法,我应该在 xml 文件中编写什么内容才能获得正确的 o/p。 谢谢

In my application i have an activity which extends ExpandableListActivity, there i want to put a button at the end of ExpandableListview, so that if i exapand it should be at the end of listview.

The problem is after exapanding all the items in Expandablelistview it takes the full screen and the button does not appear.
How can I scroll button with ExpandableListview?
I also tried to give Scrollview but its not working.
Give me a way what should I write in xml file for proper o/p.
Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七秒鱼° 2024-11-25 10:37:02

创建一个由要设置为页脚的 Button 组成的 footerview 布局,然后尝试

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> 

Create a footerview layout consisting of Button that you want to set as footer and then try

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

Footer_layout xml file

<?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> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文