title: How to display database table records using TableLayout
body: <p>I followed the "<a href="https://stackoverflow.com/questions/17987212/how-to-get-data-from-database-in-my-android-table-view-as-columns/20114467#20114467">How to get data from database in my android table view as columns</a>" link to resolve my problem
  but a blank screen appears without data. On clicking the button I have written code to fetch the records from MS SQL DB.</p>
  
  <p>My XML, for layout purpose, activity_display_result.xml:</p>
  
  <pre><code>&lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:id="@+id/tab" &gt;
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p>And the code snippet from <em>MainActivity.java</em>:</p>
  
  <pre><code>@SuppressLint("NewApi") @Override
  public void onCreate(Bundle b)
  {
      super.onCreate(b);
      setContentView(R.layout.activity_main);
  
      if( Build.VERSION.SDK_INT &gt;= 9)
      {
          StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
          StrictMode.setThreadPolicy(policy); 
      }
  
      initilize();
  
      button1.setOnClickListener(new OnClickListener() 
      {
          public void onClick(View v) 
          {
              List &lt;Map&lt;String,String&gt;&gt; dataList  = querySQL(e1.getText().toString(),e2.getText().toString(),e.getText().toString());
  
              StringBuilder builder = new StringBuilder();
              for (int i=0;i&lt;dataList.size();i++)
              {               
                 Log.i("onClick Method()", "UserName : "+dataList.get(i).get("UserName"));
                 Log.i("onClick Method()", "Password : "+dataList.get(i).get("Password"));
                 builder.append(dataList.get(i).get("UserName")).append(";").
                 append(dataList.get(i).get("Password")).append("_");
              }
  
              builder.toString();
  
              String st = new String(builder);
              String[] rows =st.split("_");
              setContentView(R.layout.activity_display_result);
              TableLayout tableLayout =(TableLayout) findViewById(R.id.tab);
              tableLayout.removeAllViews();
  
              for(int i=0;i&lt;rows.length;i++)
              {
                  String row  = rows[i];
                  TableRow tableRow = new TableRow(getApplicationContext());
                                                  tableRow.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  
                  final String[] cols = row.split(";");
  
                  Log.i("MainActivity ","Column length :"+cols.length);
  
                  //Handler handler = null;
  
                  for (int j = 0; j &lt; cols.length; j++) 
                  {             
                      final String col = cols[j];                                 
                      TextView TextView11 = new TextView(getApplicationContext());
                      TextView11.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
                      TextView11.setTextColor(color.black);
                      //TextView11.setText(String.format("%7s", col));
                      TextView11.setText(col);
                      tableRow.addView(TextView11);
                  }
  
                  tableLayout.addView(tableRow);
                  setContentView(R.layout.activity_display_result);
              }
          }
      });
  }
  </code></pre>
  
  <p>Declaring all</p>
  
  <pre><code>public void declere()
  {
      e = (EditText)findViewById(R.id.editText3);
      e1 = (EditText)findViewById(R.id.editText1);
      e2 = (EditText)findViewById(R.id.editText2);
      button1=(Button)findViewById(R.id.button1);
  }
  
  //initializing 
  public void initilize()
  {
      Log.i("initilize() Method", "initilize() Method is called..Now Calling declere() method");
      declere();
      Log.i("initilize() Method", "declere() method is called ");
      Log.i("initilize() Method", "Before Calling CONN() method..");
      connect=CONN("sa","C!@C2@!2","RequestCenter");
      Log.i("initilize() Method", "CONN() method called Successfully..");
  
   }
  </code></pre>
  
  <p>I also added one CONN method for getting connection. Can anyone help me to determine why the screen appears blank ?</p>