ListView下面跟着button

 


button随着listView的item增加而动,button始终在listView的下面, 如果满屏了,button就会固定在最底部。

代码如下:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    >

    <ListView
        android:id="@+id/my_problem_listview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:scrollbars="none"/>


<Button
    android:id="@+id/btn_add"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:text="测试"/>

</LinearLayout>

无需ScrollView 就能解决。也适用于Recyclerview

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
WinForms中的ListViewItem按钮是一种在ListView中显示按钮的控件。ListView控件是WinForms中用于展示和编辑大量项目的强大控件。它允许我们以表格的形式显示数据,并且可以自定义每个项的外观和行为。 在ListView中显示按钮,可以为每个ListViewItem添加一个按钮来执行自定义操作。为ListViewItem添加按钮的一种常见方法是使用SubItems属性。每个ListViewItem的SubItems属性可以添加多个子项,而每个子项可以包含一个按钮。通过为每个按钮设置Click事件处理程序,我们可以为按钮定义自定义操作。 例如,我们可以创建一个包含按钮的ListViewItem列表,当用户单击按钮时,会弹出一个消息框显示该按钮所在的ListViewItem的文本。以下是一个示例代码: ```csharp ListView listView = new ListView(); // 创建按钮列 listView.Columns.Add("操作", 100); // 创建ListViewItem ListViewItem item1 = new ListViewItem("项1"); item1.SubItems.Add(new ListViewItem.ListViewSubItem(item1, "按钮1")); item1.SubItems[1].Tag = item1; // 为了在按钮的Click事件处理程序中获取ListViewItem // 添加按钮到ListViewItem Button button1 = new Button(); button1.Text = "点击我"; button1.Click += (sender, e) => { ListViewItem clickedItem = (ListViewItem)((Button)sender).Tag; MessageBox.Show(clickedItem.Text); }; listView.Controls.Add(button1); // 将按钮添加到ListView控件中 listView.Items.Add(item1); // 将ListViewItem添加到ListView控件的项目列表中 ``` 这样,当用户点击按钮时,将会弹出一个消息框,显示按钮所在的ListViewItem的文本。这就是如何使用WinForms的ListViewListViewItem按钮来实现自定义操作的简单示例。
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值