表没有得到很好的android系统中清除难度比预期的那么我犯了一个新招数来填充下一个水平文本视图布局正常的列表视图这里是如何只要按照我的领导,这是用来检索队的表
主要活动::
public class ViewAllScores extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.table_total_scores_by_exam);
generateTable();
}private void generateTable() {
// TODO Auto-generated method stub
setContentView(R.layout.table_total_scores_by_exam);
mDbHelper = new DBhelp(this);
mDbHelper.open();
String ExamID = "1";
mNotesCursor = mDbHelper.getAllTeamsScoresByExam(ExamID);
startManagingCursor(mNotesCursor);
String[] from = new String[] { mDbHelper.KEY_TEAMS_TEAMNAME,
mDbHelper.KEY_SCORES_TOTALSCORE,
mDbHelper.KEY_SCORES_TIMEELAPSED };
int[] to = new int[] { R.id.tblTablesTeamsByExamRowsTeamName,
R.id.tblTablesTeamsByExamRowsTeamScore,
R.id.tblTablesTeamsByExamRowsElapsedTime };
SimpleCursorAdapter notes = new SimpleCursorAdapter(this,
R.layout.table_teams_by_exams_rows, mNotesCursor, from, to);
setListAdapter(notes);
}
数据库活动:
public Cursor getAllTeamsScoresByExam(String examID) {
// TODO Auto-generated method stub
String where = KEY_SCORES_SCOREDEXAMID + "=?";
String[] whereArgs = new String[] { examID };
Cursor cursor = ourDatabase.query(VIEW_TEAMS_SCORES_BY_EXAM,
new String[] { KEY_SCORES_SCOREDEXAMID, KEY_SCORES_TIMEELAPSED,
KEY_SCORES_TOTALSCORE ,KEY_SCORES_TEAMTRANSID,
KEY_TEAMS_TEAMNAME }, where, whereArgs, null, null,
KEY_SCORES_TOTALSCORE+" DESC");
return cursor;
} 从数据库中的分数
R.layout.table_total_scores_by_exam:
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="99" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="33"
android:background="@drawable/cell_shape"
android:gravity="center"
android:text="Team Name"
android:textSize="30sp"
android:textStyle="bold" />
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="33"
android:background="@drawable/cell_shape"
android:gravity="center"
android:text="Total Score"
android:textSize="30sp"
android:textStyle="bold" />
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="33"
android:background="@drawable/cell_shape"
android:gravity="center"
android:text="Elapsed Time"
android:textSize="30sp"
android:textStyle="bold" />
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
R.layout.table_teams_by_exams_rows:
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="99" >
android:id="@+id/tblTablesTeamsByExamRowsTeamName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="33"
android:background="@drawable/cell_shape"
android:gravity="center"
android:text="Team Name"
android:textSize="22sp"
/>
android:id="@+id/tblTablesTeamsByExamRowsTeamScore"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="33"
android:background="@drawable/cell_shape"
android:gravity="center"
android:text="Total Score"
android:textSize="22sp"
/>
android:id="@+id/tblTablesTeamsByExamRowsElapsedTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="33"
android:background="@drawable/cell_shape"
android:gravity="center"
android:text="Elapsed Time"
android:textSize="22sp"
/>
希望这一招可以帮助