gpt4 book ai didi

android - ListView 和按钮(安卓)

转载 作者:行者123 更新时间:2023-11-30 02:11:41 24 4
gpt4 key购买 nike

我想在 listView 中增加一个下降按钮: Drawing of what I want

我尝试实现这个:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#214075"
android:layout_height="match_parent"
android:orientation="vertical" >



<ListView
android:id="@+id/listbascet"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />

<Button
android:id="@+id/sendtoEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Заказать услуги" />

</LinearLayout>

最佳答案

您最好从 XML 中删除该按钮并将其添加到另一个 XML 中。

然后您可以使用inflate 获取按钮并将其添加为页脚 View 到原始 ListView 。

这样它将位于列表的末尾并且也会滚动!

如何充气:

LayoutInflater inflater = (LayoutInflater) 
getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.mylayout, null);

Button item = (Button) view.findViewById(R.id.item); // how to reference your button

如何添加页脚:

listView.addFooterView(view); // view is the inflated layout.

this 中包含有关页脚 View 的更多详细信息也回答一下。

关于android - ListView 和按钮(安卓),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30013295/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com