【发布时间】:2013-02-19 21:16:31
【问题描述】:
我对这个 Android 应用程序很陌生,有几个问题涉及 onclick 监听器。
现在我在 ScrollView 中有一个表格,其中一列包含多个按钮。 我的目标是达到一个点,我可以单击一个按钮,然后第二个表格会出现在第一个表格旁边(与第一个表格相同的布局),但有一组不同的按钮。有人可以指导我正确的方向吗?
如果您有任何问题,请告诉我。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation='vertical' >
<ScrollView
android:layout_width="125dp"
android:layout_height="200dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout android:id="@+id/table_right"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow android:id="@+id/row_1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/Button_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
android:textSize="20dp" >
</Button>
</TableRow>
<TableRow android:id="@+id/row_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/Button_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2"
android:textSize="25dp" >
</Button>
</TableRow>
<TableRow android:id="@+id/row_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/Button_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 3"
android:textSize="25dp" >
</Button>
</TableRow>
<TableRow android:id="@+id/row_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/Button_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 4"
android:textSize="25dp" >
</Button>
</TableRow>
<TableRow android:id="@+id/row_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/Button_5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 5"
android:textSize="25dp" >
</Button>
</TableRow>
<TableRow android:id="@+id/row_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button android:id="@+id/Button_6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 6"
android:textSize="25dp" >
</Button>
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
【问题讨论】:
-
是的,请列出您的代码以便我们为您提供帮助
-
为按钮设置标签并处理它。
-
我添加了到目前为止的内容
标签: android layout button tablelayout onclicklistener