在Android的表视图中显示的数据

在Android的表视图中显示的数据

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

问题描述

限时删除!!

我想获得的数据由数据库在我的Andr​​oid 表视图

我应该使用循环?是静态的好呢?

解决方案

  RS1 = stmt.executeQuery(SELECT * FROM信息);

            StringBuilder的SB =新的StringBuilder();
            而(rs1.next())
            {
                字符串脚本= rs1.getString(1);
                字符串调用= rs1.getString(2);
                串价格= rs1.getString(3);
                串止损= rs1.getString(4);
                目标字符串= rs1.getString(5);
                串LTP = rs1.getString(6);
                串出口= 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();
 

有关这一点,你有XML为此,有像

一个XML

 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT
    机器人:方向=横向机器人:layout_marginTop =20dip>
    < TableLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:ID =@ + ID /标签
    >
      <的TableRow>
      < /的TableRow>
    < / TableLayout>
< / LinearLayout中>
 

展现在你写的Andr​​oid的数据。

 字符串ST =新的String(STR);
        Log.e(主,ST);
        的String []行= st.split(_);
        TableLayout tableLayout =(TableLayout)findViewById(R.id.tab);
        tableLayout.removeAllViews();


        的for(int i = 0; I< rows.length;我++){
            串行=行[I]
            的TableRow的TableRow =新的TableRow(getApplicationContext());
            最终的String [] COLS = row.split();

            处理程序处理程序= NULL;

            对于(INT J = 0; J< cols.length; J ++){

                最后弦乐COL = COLS [J]。
                最后的TextView columsView =新的TextView(getApplicationContext());
                columsView.setText(的String.Format(%7S,列));
                tableRow.addView(columsView);
 

I want to get data from database in my android table view.

Should I use loop? Is static good for this?

解决方案
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();

for this you have XMLfor this you have a XML like

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:orientation="horizontal" android:layout_marginTop="20dip">
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/tab"
    >
      <TableRow>
      </TableRow>
    </TableLayout>
</LinearLayout>

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的表视图中显示的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:59