【发布时间】:2011-11-30 13:13:03
【问题描述】:
我只是想知道如何调用/附加/发送带有文本的表格到按钮。我可以让 ListView 正常工作,但我不知道 TableLayout 背后的“想法”。我想做的就是:按下按钮时,它应该转到表格并显示文本。我不是在寻找任何花哨的东西,只是在按下按钮时在表格中显示文本。我在这样的菜单上设置了一个按钮(名为 buttonInfo.java):
Button btnInfo = (Button) findViewById(R.id.buttonInfo);
btnInfo.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.crazyj.peopleinfo.BUTTONINFO"));
}
});
这是带有文本的表格(名为 infotable.xml):
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<TextView android:text="Name"
android:padding="3dip" />
<TextView android:text="John"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView android:text="Number"
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView android:text="Age"
android:padding="3dip" />
<TextView android:text="32"
android:gravity="right"
android:padding="3dip" />
</TableRow>
</TableLayout>
buttonInfo 类:
package com.crazyj.peopleinfo;
import android.content.Context;
import android.widget.TableLayout;
public class buttonInfo extends TableLayout{
public buttonInfo(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
}
如果有人可以回答这个问题,请解释它的含义!我是来学习的,而不仅仅是得到答案。谢谢!
【问题讨论】:
-
你能发布你的 buttonInfo.java 类吗
-
这就是我需要帮助的地方。你如何设置类来调用表?我可以发布我拥有的东西,但它非常丑陋!
标签: java android button tablelayout