Android 中的点网网格视图功能

Dot net grid view functionality in Android

如何像在 dot net 中那样在 android 中绑定 GridView。请参阅下面的代码,它将为每个 row.Is 提供删除按钮,在 android.

中有任何类似的功能
<asp:GridView ID="gvSample" runat="server" Width="100%" 
                        AutoGenerateColumns="false" DataKeyNames="ID,Place,MAddress" OnRowCommand="gvSensors_RowCommand">
    <Columns>
        <asp:BoundField DataField="DeviceName" HeaderText="S ID">
        <ItemStyle HorizontalAlign="Center" />
        </asp:BoundField>
       <asp:BoundField DataField="MCountry" HeaderText="COUNTRY">
        <ItemStyle HorizontalAlign="Center" />
        </asp:BoundField>
        <asp:BoundField DataField="MState" HeaderText="STATE">
        <ItemStyle HorizontalAlign="Center" />
        </asp:BoundField>
        <asp:TemplateField HeaderText="Select">
        <ItemTemplate>
            <asp:ImageButton ID="BtnSelect" ImageUrl="~/img/select.png" runat="server" CausesValidation="False"
            CommandArgument='<%#((GridViewRow) Container).RowIndex %>' CommandName="Select" />
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" />
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Delete">
        <ItemTemplate>
            <asp:ImageButton ID="lnkbtnDelete" ImageUrl="~/img/delete.png" runat="server" CausesValidation="False"
            CommandArgument='<%#((GridViewRow) Container).RowIndex %>' CommandName="DeleteC" />
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" />
        </asp:TemplateField>
    </Columns>
</asp:GridView>

在 android 中 IDESDK 没有提供这样的自动功能。

首先,您需要创建自定义 xml layout,让您的字段带有 Select 和删除按钮,然后您必须使用 layoutCustom Adapter GridView。您可以将 RecyclerViewGridLayoutManager 一起使用。你会得到很多关于如何做这些事情的教程。

它们在 android 中没有直接功能,在 dotnet 中,它是 table 而不是网格,因为所有行都定义单个项目。为此,您可以使用 listView,每个列表项都跨越具有选项视图(如删除)的项目属性。单击删除时,从列表中删除项目并在列表适配器中调用 notifyDataSetChanged。