如何在android中的表视图中显示我的数据 [英] how to display my data in a table view in android

查看:75
本文介绍了如何在android中的表视图中显示我的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




i使用Android

应用程序从数据库中检索了一些信息。

我想通过一个显示这些数据我的应用程序中的表格格式。

Hi
i have retrieved some information from database using Android
application.
I want to display this data via a table format in my application.

推荐答案

这个示例代码是另一个网站,我在这里写道:

我希望对你有用:



This sample code was another site and I write here:
I hope useful for you:

rs1 = stmt.executeQuery("SELECT * from message");

        StringBuilder sb = new StringBuilder();
        while (rs1.next())
        {
            String script = rs1.getString(1);
            String call =  rs1.getString(2);
            String price =  rs1.getString(3);
            String stoploss =  rs1.getString(4);
            String target =  rs1.getString(5);
            String ltp =  rs1.getString(6);
            String exit =  rs1.getString(7);
            sb.append(script).append(";").append(call).append(";").append(price).append(";").append(stoploss).append(";").append(target).append(";").append(ltp).append(";").append(exit).append("_");
        }
        out.print(sb.toString());
        out.flush();





显示你写的android中的数据。



String st = new String(str);

Log.e(Main,st); String [] rows = st.split(_); TableLayout tableLayout =(TableLayout)findViewById(R.id.tab); tableLayout.removeAllViews();







to show the data in the android you write.

String st = new String(str);
Log.e("Main",st); String[] rows = st.split("_"); TableLayout tableLayout = (TableLayout)findViewById(R.id.tab); tableLayout.removeAllViews();


for(int i=0;i<rows.length;i++){>
            String row  = rows[i];
            TableRow tableRow = new TableRow(getApplicationContext());
            final String[] cols = row.split(";");

            Handler handler = null;

            for (int j = 0; j < cols.length; j++) {

                final String col = cols[j];                                 
                final TextView columsView = new TextView(getApplicationContext());
                columsView.setText(String.format("%7s", col));                              
                tableRow.addView(columsView);


这篇关于如何在android中的表视图中显示我的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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