Advertisement
Guest User

nag

a guest
Aug 4th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.50 KB | None | 0 0
  1. //XML file
  2.  
  3. <TableLayout android:background="#cfe1edFF" android:id="@+id/tl"
  4.   android:layout_width="fill_parent"
  5.   android:layout_height="wrap_content" >
  6.  
  7.   <TableRow>
  8.     <TextView android:text="Symbol"
  9.     android:layout_height="fill_parent" android:textColor="#104e8b"
  10.         android:layout_width="wrap_content"
  11.         android:layout_weight="1" android:gravity="center" android:background="@drawable/shapefile"/>
  12.     <TextView android:text="A/c Type"
  13.     android:layout_height="fill_parent" android:textColor="#104e8b"
  14.         android:layout_width="wrap_content"
  15.         android:layout_weight="1" android:gravity="center" android:background="@drawable/shapefile">
  16.     </TextView>
  17.     <TextView android:text="Position" android:textColor="#104e8b" android:layout_height="fill_parent"
  18.         android:layout_width="wrap_content"
  19.         android:layout_weight="1" android:gravity="center" android:background="@drawable/shapefile">
  20.     </TextView>
  21.   </TableRow>
  22.  
  23.     <ScrollView>      
  24.     <TableLayout android:id="@+id/score_table"
  25.       android:layout_width="fill_parent"
  26.       android:layout_height="wrap_content">
  27.     </TableLayout>
  28.   </ScrollView>    
  29. </TableLayout>
  30.  
  31. //Code to bind arraylist to TableLayout
  32.  
  33. public void TableBinding(ArrayList<Position> posLst)
  34.     {
  35.         String data="";
  36.         TextView tvv=(TextView)findViewById(R.id.txtView);
  37.         for(int i=0;i<posLst.size();i++)
  38.         {          
  39.             Position pos=posLst.get(i);
  40.             String msg=pos.Symbol+pos.AcType+pos.Position;
  41.             data=data+msg;            
  42.         }
  43.         tvv.setText(data);
  44.         TableLayout tLayout=(TableLayout)findViewById(R.id.score_table);       
  45.         for(int i=0;i<posLst.size();i++)
  46.         {
  47.             TableRow tr = new TableRow(this);
  48.            
  49.             TextView b = new TextView(this);
  50.             createView(tr, b, posLst.get(i).Symbol);
  51.  
  52.  
  53.             TextView b1 = new TextView(this);
  54.             createView(tr, b1, posLst.get(i).AcType);
  55.  
  56.             TextView b2 = new TextView(this);
  57.             createView(tr, b2, posLst.get(i).Position);
  58.  
  59.            
  60.  
  61.             /* Add row to TableLayout. */
  62.             tLayout.addView(tr);
  63.  
  64.         }
  65.  
  66.     }
  67.     public void createView(TableRow tr, TextView t, String viewdata) {
  68.         t.setText(viewdata);
  69.         t.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  70.         t.setTextColor(Color.DKGRAY);
  71.         t.setPadding(20, 0, 0, 0);
  72.         tr.setPadding(0, 1, 0, 1);
  73.         tr.addView(t);
  74.     }
  75.  
  76. //From above XML code i'm using TableLayout with in TableLayout
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement