2017-04-10 26 views
0

m beginner at Java coding and would like to use ad advice. Sorry for basic question, butu I couldn找到我正在尋找。Android活動中的框架/表格?

我想閱讀SqLite數據庫並將其數據顯示在mainactivity中。 下面是它應該看起來的一個例子(例如有兩行--1和2)。

activity example

問題是我應該用哪一種方法/類來創建將在SQLITE行數自動更新築底幀(例如,在1和2)。 這意味着如果SqLite有5行,我想有5個框架可以顯示數據。

在此先感謝。

回答

1

你必須使用Android ListViewRecyclerView你定義適配器或者你可以使用默認的適配器ListView

閱讀更多關於ListViewRecyclerView

https://developer.android.com/guide/topics/ui/layout/listview.html

https://developer.android.com/training/material/lists-cards.html

+0

適配器基於視圖可能是矯枉過正,因爲沒有滾動或查看說明要求回收 – RobCo

+0

謝謝。滾動將是一項資產。 另一個問題。是否有可能使特定的單元格在RecyclerView中可點擊或只有整行可點擊? – Michal

+0

@RobCo根據這個問題,開發人員不確定內容大小。所以我認爲回收視圖不會矯枉過正。這將是一個節省。 – Rahul

0

您可以使用GridView控件或RecyclerView和使用適配器設置數據。

因此,當你有5行。它會將數據設置爲5行。此外,GridView或Recycler視圖將爲您提供平滑的滾動效果。

0

這裏分享一個例子。 DBManager是一個可以用來添加,刪除,更新行的界面。 MainActivity顯示它的用法。

package in.apachetechnology.apachedb; 

import android.content.ContentValues; 
import android.content.Context; 
import android.database.Cursor; 
import android.database.SQLException; 
import android.database.sqlite.SQLiteDatabase; 
import android.database.sqlite.SQLiteOpenHelper; 
import android.util.Log; 

import java.util.ArrayList; 

public class DBManager 
{ 
    // the Activity or Application that is creating an object from this class. 
    Context m_oContext; 

    // a reference to the database used by this application/object 
    private SQLiteDatabase m_sqlDB; 

    // These constants are specific to the database. They should be 
    // changed to suit your needs. 
    private final String cDB_NAME = "database_name"; 
    private final int cDB_VERSION = 1; 

    // These constants are specific to the database table. They should be 
    // changed to suit your needs. 
    private final String cTABLE_NAME = "database_table"; 
    private final String cROW_NAME_ID = "id"; 
    private final String cROW_NAME_ONE = "table_row_one"; 
    private final String cROW_NAME_TWO = "table_row_two"; 

    public DBManager(Context c) 
    { 
     m_oContext = c; 

     // create or open the database 
     CustomSQLiteOpenHelper helper = new CustomSQLiteOpenHelper(c); 
     m_sqlDB = helper.getWritableDatabase(); 
    } 

    /********************************************************************** 
    * ADDING A ROW TO THE DATABASE TABLE 
    * 
    * This is an example of how to add a row to a database table 
    * using this class. You should edit this method to suit your 
    * needs. 
    * 
    * the key is automatically assigned by the database 
    * @param rowStringOne the value for the row's first column 
    * @param rowStringTwo the value for the row's second column 
    */ 
    public void addRow(String rowStringOne, String rowStringTwo) 
    { 
     // this is a key value pair holder used by android's SQLite  functions 
     ContentValues values = new ContentValues(); 
     values.put(cROW_NAME_ONE, rowStringOne); 
     values.put(cROW_NAME_TWO, rowStringTwo); 

     // ask the database object to insert the new data 
     try{ 
      m_sqlDB.insert(cTABLE_NAME, null, values);} 
     catch(Exception e) { 
      Log.e("DB ERROR", e.toString()); 
      e.printStackTrace(); 
     } 
    } 

    /********************************************************************** 
    * DELETING A ROW FROM THE DATABASE TABLE 
    * 
    * This is an example of how to delete a row from a database table 
    * using this class. In most cases, this method probably does 
    * not need to be rewritten. 
    * 
    * @param rowID the SQLite database identifier for the row to delete. 
    */ 
    public void deleteRow(long rowID) 
    { 
     // ask the database manager to delete the row of given id 
     try { 
     m_sqlDB.delete(cTABLE_NAME, cROW_NAME_ID + "=" + rowID, null);} 
     catch (Exception e) { 
      Log.e("DB ERROR", e.toString()); 
      e.printStackTrace(); 
     } 
    } 

    /********************************************************************** 
    * UPDATING A ROW IN THE DATABASE TABLE 
    * 
    * This is an example of how to update a row in the database table 
    * using this class. You should edit this method to suit your needs. 
    * 
    * @param rowID the SQLite database identifier for the row to update. 
    * @param rowStringOne the new value for the row's first column 
    * @param rowStringTwo the new value for the row's second column 
    */ 
    public void updateRow(long rowID, String rowStringOne, String rowStringTwo) 
    { 
     // this is a key value pair holder used by android's SQLite functions 
     ContentValues values = new ContentValues(); 
     values.put(cROW_NAME_ONE, rowStringOne); 
     values.put(cROW_NAME_TWO, rowStringTwo); 

     // ask the database object to update the database row of given rowID 
     try { 
      m_sqlDB.update(cTABLE_NAME, values, cROW_NAME_ID + "=" + rowID, null);} 
     catch (Exception e) { 
      Log.e("DB Error", e.toString()); 
      e.printStackTrace(); 
     } 
    } 

    /********************************************************************** 
    * RETRIEVING A ROW FROM THE DATABASE TABLE 
    * 
    * This is an example of how to retrieve a row from a database table 
    * using this class. You should edit this method to suit your needs. 
    * 
    * @param rowID the id of the row to retrieve 
    * @return an array containing the data from the row 
    */ 
    public ArrayList<Object> getRowAsArray(long rowID) 
    { 
     // create an array list to store data from the database row. 
     // I would recommend creating a JavaBean compliant object 
     // to store this data instead. That way you can ensure 
     // data types are correct. 
     ArrayList<Object> rowArray = new ArrayList<Object>(); 
     Cursor cursor; 

     try 
     { 
      // this is a database call that creates a "cursor" object. 
      // the cursor object store the information collected from the 
      // database and is used to iterate through the data. 
      cursor = m_sqlDB.query(
       cTABLE_NAME, 
       new String[] { cROW_NAME_ID, cROW_NAME_ONE, cROW_NAME_TWO }, 
       cROW_NAME_ID + "=" + rowID, 
       null, null, null, null, null 
      ); 

      // move the pointer to position zero in the cursor. 
      cursor.moveToFirst(); 

      // if there is data available after the cursor's pointer, add 
      // it to the ArrayList that will be returned by the method. 
      if (!cursor.isAfterLast()) { 
       do { 
        rowArray.add(cursor.getLong(0)); 
        rowArray.add(cursor.getString(1)); 
        rowArray.add(cursor.getString(2)); 
       } 
       while (cursor.moveToNext()); 
      } 

      // let java know that you are through with the cursor. 
      cursor.close(); 
     } 
     catch (SQLException e) { 
      Log.e("DB ERROR", e.toString()); 
      e.printStackTrace(); 
     } 

     // return the ArrayList containing the given row from the database. 
     return rowArray; 
    } 

    /********************************************************************** 
    * RETRIEVING ALL ROWS FROM THE DATABASE TABLE 
    * 
    * This is an example of how to retrieve all data from a database 
    * table using this class. You should edit this method to suit your 
    * needs. 
    * 
    * the key is automatically assigned by the database 
    */ 

    public ArrayList<ArrayList<Object>> getAllRowsAsArrays() 
    { 
     // create an ArrayList that will hold all of the data collected from 
     // the database. 
     ArrayList<ArrayList<Object>> dataArrays = new ArrayList<ArrayList<Object>>(); 

     // this is a database call that creates a "cursor" object. 
     // the cursor object store the information collected from the 
     // database and is used to iterate through the data. 
     Cursor cursor; 

     try { 
      // ask the database object to create the cursor. 
      cursor = m_sqlDB.query(
       cTABLE_NAME, 
       new String[]{cROW_NAME_ID, cROW_NAME_ONE, cROW_NAME_TWO}, 
       null, null, null, null, null 
      ); 

      // move the cursor's pointer to position zero. 
      cursor.moveToFirst(); 

      // if there is data after the current cursor position, add it 
      // to the ArrayList. 
      if (!cursor.isAfterLast()) { 
       do { 
        ArrayList<Object> dataList = new ArrayList<Object>(); 

        dataList.add(cursor.getLong(0)); 
        dataList.add(cursor.getString(1)); 
        dataList.add(cursor.getString(2)); 

        dataArrays.add(dataList); 
       } 
       // move the cursor's pointer up one position. 
       while (cursor.moveToNext()); 
      } 
     } catch (SQLException e) { 
      Log.e("DB Error", e.toString()); 
      e.printStackTrace(); 
     } 

     // return the ArrayList that holds the data collected from 
     // the database. 
     return dataArrays; 
    } 

    /** 
    * This class is designed to check if there is a database that currently 
    * exists for the given program. If the database does not exist, it  creates 
    * one. After the class ensures that the database exists, this class 
    * will open the database for use. Most of this functionality will be 
    * handled by the SQLiteOpenHelper parent class. The purpose of extending 
    * this class is to tell the class how to create (or update) the database. 
    */ 
    private class CustomSQLiteOpenHelper extends SQLiteOpenHelper 
    { 
     public CustomSQLiteOpenHelper(Context m_oContext) 
     { 
      super(m_oContext, cDB_NAME, null, cDB_VERSION); 
     } 

     @Override 
     public void onCreate(SQLiteDatabase m_sqlDB) 
     { 
      // This string is used to create the database. It should 
      // be changed to suit your needs. 
      String newTableQueryString = "create table " + 
            cTABLE_NAME + 
            " (" + 
            cROW_NAME_ID + " integer primary key autoincrement not null," + 
            cROW_NAME_ONE + " text," + 
            cROW_NAME_TWO + " text" + 
            ");"; 
      // execute the query string to the database. 
      m_sqlDB.execSQL(newTableQueryString); 
     } 

     @Override 
     public void onUpgrade(SQLiteDatabase m_sqlDB, int oldVersion, int newVersion) 
     { 
      // NOTHING TO DO HERE. THIS IS THE ORIGINAL DATABASE VERSION. 
      // OTHERWISE, YOU WOULD SPECIFIY HOW TO UPGRADE THE DATABASE. 
     } 
    } 
} 

MainActivity

public class MainActivity extends Activity { 

    // the text fields that users input new data into 
    EditText textFieldOne, textFieldTwo, 
      idField, 
      updateIDField, updateTextFieldOne, updateTextFieldTwo; 

    // the buttons that listen for the user to select an action 
    Button addButton, deleteButton, retrieveButton, updateButton; 

    // the table that displays the data 
    TableLayout dataTable; 

    // the class that opens or creates the database and makes sql calls to it 
    DBManager db; 

    /** 
    * Called when the activity is first created. 
    */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     // this try catch block returns better error reporting to the log 
     try { 
      // Android specific calls 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.activity_main); 
      // create the database manager object 
      db = new DBManager(this); 

      // create references and listeners for the GUI interface 
      setupViews(); 

      // make the buttons clicks perform actions 
      addButtonListeners(); 

      // load the data table 
      updateTable(); 
     } catch (Exception e) { 
      Log.e("ERROR", e.toString()); 
      e.printStackTrace(); 
     } 
    } 

    /** 
    * creates references and listeners for the GUI interface 
    */ 
    private void setupViews() { 
     // THE DATA TABLE 
     dataTable = (TableLayout) findViewById(R.id.data_table); 

     // THE DATA FORM FIELDS 
     textFieldOne = (EditText) findViewById(R.id.text_field_one); 
     textFieldTwo = (EditText) findViewById(R.id.text_field_two); 
     idField = (EditText) findViewById(R.id.id_field); 
     updateIDField = (EditText) findViewById(R.id.update_id_field); 
     updateTextFieldOne = (EditText) findViewById(R.id.update_text_field_one); 
     updateTextFieldTwo = (EditText) findViewById(R.id.update_text_field_two); 

     // THE BUTTONS 
     addButton = (Button) findViewById(R.id.add_button); 
     deleteButton = (Button) findViewById(R.id.delete_button); 
     retrieveButton = (Button) findViewById(R.id.retrieve_button); 
     updateButton = (Button) findViewById(R.id.update_button); 
    } 

    /** 
    * adds listeners to each of the buttons and sets them to call relevant methods 
    */ 
    private void addButtonListeners() { 
     addButton.setOnClickListener 
       (
         new View.OnClickListener() { 
          @Override 
          public void onClick(View v) { 
           addRow(); 
          } 
         } 
       ); 

     deleteButton.setOnClickListener 
       (
         new View.OnClickListener() { 
          @Override 
          public void onClick(View v) { 
           deleteRow(); 
          } 
         } 
       ); 

     updateButton.setOnClickListener 
       (
         new View.OnClickListener() { 
          @Override 
          public void onClick(View v) { 
           updateRow(); 
          } 
         } 
       ); 

     retrieveButton.setOnClickListener 
       (
         new View.OnClickListener() { 
          @Override 
          public void onClick(View v) { 
           retrieveRow(); 
          } 
         } 
       ); 

    } 

    /** 
    * adds a row to the database based on information contained in the 
    * add row fields. 
    */ 
    private void addRow() { 
     try { 
      // ask the database manager to add a row given the two strings 
      db.addRow 
        (
          textFieldOne.getText().toString(), 
          textFieldTwo.getText().toString() 
        ); 

      // request the table be updated 
      updateTable(); 

      // remove all user input from the Activity 
      emptyFormFields(); 
     } catch (Exception e) { 
      Log.e("Add Error", e.toString()); 
      e.printStackTrace(); 
     } 
    } 

    /** 
    * deletes a row from the database with the id number in the corresponding 
    * user entry field 
    */ 
    private void deleteRow() { 
     try { 
      // ask the database manager to delete the row with the give rowID. 
      db.deleteRow(Long.parseLong(idField.getText().toString())); 

      // request the table be updated 
      updateTable(); 

      // remove all user input from the Activity 
      emptyFormFields(); 
     } catch (Exception e) { 
      Log.e("Delete Error", e.toString()); 
      e.printStackTrace(); 
     } 
    } 

    /** 
    * retrieves a row from the database with the id number in the corresponding 
    * user entry field 
    */ 
    private void retrieveRow() { 
     try { 
      // The ArrayList that holds the row data 
      ArrayList<Object> row; 
      // ask the database manager to retrieve the row with the given rowID 
      row = db.getRowAsArray(Long.parseLong(updateIDField.getText().toString())); 

      // update the form fields to hold the retrieved data 
      updateTextFieldOne.setText((String) row.get(1)); 
      updateTextFieldTwo.setText((String) row.get(2)); 
     } catch (Exception e) { 
      Log.e("Retrieve Error", e.toString()); 
      e.printStackTrace(); 
     } 
    } 

    /** 
    * updates a row with the given information in the corresponding user entry 
    * fields 
    */ 
    private void updateRow() { 
     try { 
      // ask the database manager to update the row based on the information 
      // found in the corresponding user entry fields 
      db.updateRow 
        (
          Long.parseLong(updateIDField.getText().toString()), 
          updateTextFieldOne.getText().toString(), 
          updateTextFieldTwo.getText().toString() 
        ); 

      // request the table be updated 
      updateTable(); 

      // remove all user input from the Activity 
      emptyFormFields(); 
     } catch (Exception e) { 
      Log.e("Update Error", e.toString()); 
      e.printStackTrace(); 
     } 
    } 

    /** 
    * helper method to empty all the fields in all the forms. 
    */ 
    private void emptyFormFields() { 
     textFieldOne.setText(""); 
     textFieldTwo.setText(""); 
     idField.setText(""); 
     updateIDField.setText(""); 
     updateTextFieldOne.setText(""); 
     updateTextFieldTwo.setText(""); 
    } 

    /** 
    * updates the table from the database. 
    */ 
    private void updateTable() { 
     // delete all but the first row. remember that the count 
     // starts at one and the index starts at zero 
     while (dataTable.getChildCount() > 1) { 
      // while there are at least two rows in the table widget, delete 
      // the second row. 
      dataTable.removeViewAt(1); 
     } 

     // collect the current row information from the database and 
     // store it in a two dimensional ArrayList 
     ArrayList<ArrayList<Object>> data = db.getAllRowsAsArrays(); 

     // iterate the ArrayList, create new rows each time and add them 
     // to the table widget. 
     for (int position = 0; position < data.size(); position++) { 
      TableRow tableRow = new TableRow(this); 

      ArrayList<Object> row = data.get(position); 

      TextView idText = new TextView(this); 
      idText.setText(row.get(0).toString()); 
      tableRow.addView(idText); 

      TextView textOne = new TextView(this); 
      textOne.setText(row.get(1).toString()); 
      tableRow.addView(textOne); 

      TextView textTwo = new TextView(this); 
      textTwo.setText(row.get(2).toString()); 
      tableRow.addView(textTwo); 

      dataTable.addView(tableRow); 
     } 
    } 
} 

XML

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="center_horizontal" 
    android:background="#736f6e" 
    > 

    <!-- ADD A DATA ENTRY FORM --> 
    <TextView 
     android:text="@string/add_directions" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     /> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     > 
     <EditText 
      android:id="@+id/text_field_one" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="100px" 
      /> 
     <EditText 
      android:id="@+id/text_field_two" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="100px" 
      /> 
     <Button 
      android:id="@+id/add_button" 
      android:text="@string/add" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
     android:minWidth="100px" 
      /> 
    </LinearLayout> 

    <!-- DELETE A DATA ENTRY FORM --> 
    <TextView 
     android:text="@string/delete_directions" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     /> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     > 
     <EditText 
      android:id="@+id/id_field" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="100px" 
      /> 
     <Button 
      android:id="@+id/delete_button" 
      android:text="@string/delete" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      /> 
    </LinearLayout> 

    <!-- UPDATE A DATA ENTRY FORM --> 
    <TextView 
     android:text="@string/update_directions" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     /> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     > 
     <EditText 
      android:id="@+id/update_id_field" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="45px" 
      />   
     <Button 
      android:id="@+id/retrieve_button" 
      android:text="@string/retrieve" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      /> 
     <EditText 
      android:id="@+id/update_text_field_one" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="70px" 
      /> 
     <EditText 
      android:id="@+id/update_text_field_two" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="70px" 
      /> 
     <Button 
      android:id="@+id/update_button" 
      android:text="@string/update" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      /> 

    </LinearLayout> 

    <ScrollView 
     android:id="@+id/tbl_scrollbar" 
     android:scrollbars="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:scrollbarStyle="insideOverlay" 
     android:scrollbarSize="12px" 
     > 
    <!-- THE DATA TABLE --> 
    <TableLayout 
     android:id="@+id/data_table" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:stretchColumns="*" 
     > 
     <TableRow> 
      <TextView 
       android:text="@string/th_id" 
       android:minWidth="50px" 
       /> 
      <TextView 
       android:text="@string/th_text_one" 
       android:minWidth="125px" 
       /> 
      <TextView 
       android:text="@string/th_text_two" 
       android:minWidth="125px" 
       /> 
     </TableRow> 
    </TableLayout> 
    </ScrollView> 
</LinearLayout> 

MyTask.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="center_horizontal" 
    android:background="#736f6e" 
    > 

    <!-- ADD A DATA ENTRY FORM --> 
    <TextView 
     android:text="@string/add_directions" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     /> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     > 
     <EditText 
      android:id="@+id/text_field_one" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="100px" 
      /> 
     <EditText 
      android:id="@+id/text_field_two" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="100px" 
      /> 
     <Button 
      android:id="@+id/add_button" 
      android:text="@string/add" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
     android:minWidth="100px" 
      /> 
    </LinearLayout> 

    <!-- DELETE A DATA ENTRY FORM --> 
    <TextView 
     android:text="@string/delete_directions" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     /> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     > 
     <EditText 
      android:id="@+id/id_field" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="100px" 
      /> 
     <Button 
      android:id="@+id/delete_button" 
      android:text="@string/delete" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      /> 
    </LinearLayout> 

    <!-- UPDATE A DATA ENTRY FORM --> 
    <TextView 
     android:text="@string/update_directions" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     /> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     > 
     <EditText 
      android:id="@+id/update_id_field" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="45px" 
      />   
     <Button 
      android:id="@+id/retrieve_button" 
      android:text="@string/retrieve" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      /> 
     <EditText 
      android:id="@+id/update_text_field_one" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="70px" 
      /> 
     <EditText 
      android:id="@+id/update_text_field_two" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:minWidth="70px" 
      /> 
     <Button 
      android:id="@+id/update_button" 
      android:text="@string/update" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      /> 

    </LinearLayout> 

    <ScrollView 
     android:id="@+id/tbl_scrollbar" 
     android:scrollbars="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:scrollbarStyle="insideOverlay" 
     android:scrollbarSize="12px" 
     > 
    <!-- THE DATA TABLE --> 
    <TableLayout 
     android:id="@+id/data_table" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:stretchColumns="*" 
     > 
     <TableRow> 
      <TextView 
       android:text="@string/th_id" 
       android:minWidth="50px" 
       /> 
      <TextView 
       android:text="@string/th_text_one" 
       android:minWidth="125px" 
       /> 
      <TextView 
       android:text="@string/th_text_two" 
       android:minWidth="125px" 
       /> 
     </TableRow> 
    </TableLayout> 
    </ScrollView> 
</LinearLayout>