title: Create Horizontal and Vertical Scroll View Dynamically Android
body: <p>In my project i managed to display the database in the form of rows and columns of edit Texts and text Views.But the as the number of rows and columns increase it is not possible to view the added data , they dont fit into the screen. 
  so i think i needed a horizontal scrollview and a vertical scrollview for viewing entire rows and columns. Below
  is my code kindly help me how to achieve this.
  Please do help me thanks in advance</p>
  
  <p>xml code is</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"&gt;
  
  
  
  &lt;TableLayout 
              android:layout_width="wrap_content"
              android:stretchColumns="0,1,2,3,4,5"
              android:id="@+id/maintable"
              android:layout_height="wrap_content"  
              android:layout_weight="1.0"&gt;
  
  &lt;/TableLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The following is the code for page where i wanna display my rows and columns</p>
  
  <pre><code>public class ViewActivity extends Activity {
  EditText col1;
  EditText col2;
  TextView Id;
  EditText col4;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_view);
      ScrollView sv = new ScrollView(this);
      HorizontalScrollView hs =new HorizontalScrollView(this);
  
      TableLayout tl = (TableLayout) findViewById(R.id.maintable);
  
      //CREATING A LIST OF HEADINGS
  
  TableRow tr1 = new TableRow(this);
      tr1.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT ));
  
      Id = new TextView(this);
      Id.setText("COL1");
      tr1.addView(Id);
  
      Id = new TextView(this);
      Id.setText("COL2");
      tr1.addView(Id);
  
      Id = new TextView(this);
      Id.setText("COL3");
      tr1.addView(Id);
  
      Id = new TextView(this);
      Id.setText("Rssi");
      tr1.addView(COL4);
  
      Id = new TextView(this);
      Id.setText("Delete");
      tr1.addView(COL5);
  
      Id = new TextView(this);
      Id.setText("Update");
      tr1.addView(COL6);
  
      hs.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
              LayoutParams.FILL_PARENT));
  
  
  
      tl.addView(tr1,new TableLayout.LayoutParams(
              LayoutParams.FILL_PARENT,
              LayoutParams.WRAP_CONTENT));  
  
      // CREATING ROWS AND COLUMNS DYNAMICALLY
  
  
      final DBclass entry = new DBclass(ViewActivity.this);
      entry.open();
      Cursor c = entry.getAllRecords();
  
      int count =0;
  
      if(c.moveToFirst()){
          do{
              TableRow tr = new TableRow(this);
              tr.setId(count);
              tr.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT ));
  
              /* CODE FOR
                COLUMNS DISPLAYED IN THE FORM OF 
                EDITTEXTS AND TEXTVIEWS
              */
  
              tl.addView(tr, new TableLayout.LayoutParams(
                      LayoutParams.FILL_PARENT,
                      LayoutParams.FILL_PARENT));
  
  
  
              count++;
          }while(c.moveToNext());
  
      }
  
  }
  </code></pre>