Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i have retrieved some information from database using Android
application.
I want to display this data via a table format in my application.
Posted

1 solution

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

Java
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();


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();


Java
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);
 
Share this answer
 
Comments
Pratik Butani 12-Aug-13 3:26am    
How to display data with lable in TableLayout?
omid.nazifi 13-Aug-13 2:10am    
what is your mean label?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900