show data in table view in android

前端 未结 6 718
自闭症患者
自闭症患者 2020-12-01 15:21

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

Should I use loop? Is static good for this?

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 15:45

    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 XML for this you have a XML like

      
        
                  
              
        
     
    

    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

提交回复
热议问题