【发布时间】:2015-10-16 15:12:40
【问题描述】:
自定义布局将是这样的 我需要使用两个编辑文本、两个按钮和每个复选框填充自定义行布局。我该怎么办。
||EDIT_TEXT ||Button
""""""""""""
||EDIT_TEXT
""""""""""""
||Chekbox ||Chekbox ||Button
我的自定义布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="250dp"
android:layout_height="50dp"
android:id="@+id/etPhone"
android:maxLength="15"
android:text=""
android:lines="1"
android:hint=" Phone Number"
android:inputType="number"
android:background="@drawable/edittext_bottom_bg"
android:digits="0123456789"
android:drawableLeft="@drawable/mobile"
android:layout_alignBottom="@+id/etAmount"
android:layout_alignLeft="@+id/etAmount"
android:layout_alignStart="@+id/etAmount" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="X"
android:id="@+id/button2"
android:layout_column="5" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="250dp"
android:layout_height="50dp"
android:id="@+id/etAmount"
android:hint=" Amount"
android:maxLength="10"
android:lines="1"
android:text=""
android:inputType="number"
android:digits="0123456789"
android:background="@drawable/edittext_bottom_bg"
android:drawableLeft="@drawable/money"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_column="0">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="PRE"
android:id="@+id/checkBox"
android:layout_weight="1" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="POST"
android:id="@+id/checkBox2"
android:layout_weight="1" />
</TableRow>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SEND"
android:id="@+id/button"
android:layout_column="1"
android:layout_weight="1" />
</TableRow>
</TableLayout>
我的主列表视图布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/a8">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvShow" />
就是这样。我没有为此创建任何类,我只想通过单击按钮在列表视图中显示该行
【问题讨论】:
-
你试过我的伪代码了吗?
-
我给你的答案是一个只有最重要的东西让你知道的布局。其余的布局你必须自己填写。像宽度,高度,也许是重量
标签: android android-listview custom-lists