Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //XML file
- <TableLayout android:background="#cfe1edFF" android:id="@+id/tl"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" >
- <TableRow>
- <TextView android:text="Symbol"
- android:layout_height="fill_parent" android:textColor="#104e8b"
- android:layout_width="wrap_content"
- android:layout_weight="1" android:gravity="center" android:background="@drawable/shapefile"/>
- <TextView android:text="A/c Type"
- android:layout_height="fill_parent" android:textColor="#104e8b"
- android:layout_width="wrap_content"
- android:layout_weight="1" android:gravity="center" android:background="@drawable/shapefile">
- </TextView>
- <TextView android:text="Position" android:textColor="#104e8b" android:layout_height="fill_parent"
- android:layout_width="wrap_content"
- android:layout_weight="1" android:gravity="center" android:background="@drawable/shapefile">
- </TextView>
- </TableRow>
- <ScrollView>
- <TableLayout android:id="@+id/score_table"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- </TableLayout>
- </ScrollView>
- </TableLayout>
- //Code to bind arraylist to TableLayout
- public void TableBinding(ArrayList<Position> posLst)
- {
- String data="";
- TextView tvv=(TextView)findViewById(R.id.txtView);
- for(int i=0;i<posLst.size();i++)
- {
- Position pos=posLst.get(i);
- String msg=pos.Symbol+pos.AcType+pos.Position;
- data=data+msg;
- }
- tvv.setText(data);
- TableLayout tLayout=(TableLayout)findViewById(R.id.score_table);
- for(int i=0;i<posLst.size();i++)
- {
- TableRow tr = new TableRow(this);
- TextView b = new TextView(this);
- createView(tr, b, posLst.get(i).Symbol);
- TextView b1 = new TextView(this);
- createView(tr, b1, posLst.get(i).AcType);
- TextView b2 = new TextView(this);
- createView(tr, b2, posLst.get(i).Position);
- /* Add row to TableLayout. */
- tLayout.addView(tr);
- }
- }
- public void createView(TableRow tr, TextView t, String viewdata) {
- t.setText(viewdata);
- t.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- t.setTextColor(Color.DKGRAY);
- t.setPadding(20, 0, 0, 0);
- tr.setPadding(0, 1, 0, 1);
- tr.addView(t);
- }
- //From above XML code i'm using TableLayout with in TableLayout
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement