我已经从数据库中创建了选项卡及其内容。现在我需要帮助弄清楚如何从这些控件中获取用户输入的值 - 如何获取选项卡上的控件列表(以便可以保存数据)。这是我如何填充选项卡内容的精简示例:
public View createTabContent(String tag)
{
SQLiteDatabase db2 = openOrCreateDatabase(msDbFile, MODE_PRIVATE, null);
Cursor cList = db2.rawQuery("SELECT * FROM CheckList WHERE CatID=" + tag, null);
TableLayout tl = new TableLayout(FormChecklist.this);
tl.setBackgroundColor(new Color().WHITE);
while(cList.moveToNext())
{
/* Create a new row to be added. */
TableRow tr = new TableRow(FormChecklist.this);
tr.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
/* Create the row-content. */
TextView lblQuestion = new TextView(FormChecklist.this);
lblQuestion.setText(cList.getString(2));
lblQuestion.setTag(tag);
/* Add control to row. */
tr.addView(lblQuestion);
CheckBox chkCompleted = new CheckBox(FormChecklist.this);
chkCompleted.setText("Completed");
chkCompleted.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
chkCompleted.setTag(tag);
/* Add control to row. */
tr.addView(chkCompleted);
/* Add row to TableLayout. */
tl.addView(tr,new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
}
db2.close();
return tl;
}