泰伯维在安卓 [英] Tableview in android

查看:119
本文介绍了泰伯维在安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  在Android的表视图数据显示

Possible Duplicate:
show data in table view in android

如何将数据在tableview中设置。 如何显示数据,实现代码如下。

how to data set in tableview. how to show data in tableview.

推荐答案

一个简单的例子:

public class MainActivity extends Activity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        TableRow.LayoutParams params = new TableRow.LayoutParams(100, 100);
        TableLayout table = new TableLayout(this);
        for (int i = 0; i < 3; i++) {
            TableRow row = new TableRow(this);
            for (int j = 0; j < 3; j++) {
                TextView text = new TextView(this);
                text.setLayoutParams(params);
                text.setText(String.format("(%d, %d)", i, j));
                row.addView(text);
            }
            table.addView(row);
        }
        setContentView(table);
    }
}

如果你能摆脱它,的GridView 和<一HREF =htt​​p://developer.android.com/reference/android/widget/ListView.html相对=nofollow> ListView控件可以更容易使用的适配器等的 ArrayAdapter 和的的CursorAdapter

If you can get away with it, GridView and ListView can be much easier to work with using adapters such as ArrayAdapter and CursorAdapter.

这篇关于泰伯维在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆