OK,這是我迄今所做的和它的作品,但如果有更好的解決方案,糾正我請。我跳過了一些我的代碼的相關部分。
Button a1,a2,a3,a4,a5,a6,a7,a8,b1,b2,b3,b4,b5,b6,b7,b8;
TextView pitanje;
a1 = (Button) findViewById(R.id.bA1);
a2 = (Button) findViewById(R.id.bA2);
a3 = (Button) findViewById(R.id.bA3);
a4 = (Button) findViewById(R.id.bA4);
a5 = (Button) findViewById(R.id.bA5);
a6 = (Button) findViewById(R.id.bA6);
a7 = (Button) findViewById(R.id.bA7);
a8 = (Button) findViewById(R.id.bA8);
b1 = (Button) findViewById(R.id.bB1);
b2 = (Button) findViewById(R.id.bB2);
b3 = (Button) findViewById(R.id.bB3);
b4 = (Button) findViewById(R.id.bB4);
b5 = (Button) findViewById(R.id.bB5);
b6 = (Button) findViewById(R.id.bB6);
b7 = (Button) findViewById(R.id.bB7);
b8 = (Button) findViewById(R.id.bB8);
pitanje = (TextView) findViewById(R.id.tvPitanje);
nextQuestion();
}
private void nextQuestion() {
TestAdapter mDbHelper = new TestAdapter(this);
mDbHelper.createDatabase();
try{
mDbHelper.open();
Cursor c = mDbHelper.getTestData(generateWhereClause());
mAnsweredQuestions.add(c.getLong(0));
pitanje.setText(c.getString(1));
List<String> labelsA = new ArrayList<String>();
List<String> labelsB = new ArrayList<String>();
labelsA.add(c.getString(2));
labelsA.add(c.getString(4));
labelsA.add(c.getString(6));
labelsA.add(c.getString(8));
labelsA.add(c.getString(10));
labelsA.add(c.getString(12));
labelsA.add(c.getString(14));
labelsA.add(c.getString(16));
labelsB.add(c.getString(3));
labelsB.add(c.getString(5));
labelsB.add(c.getString(7));
labelsB.add(c.getString(9));
labelsB.add(c.getString(11));
labelsB.add(c.getString(13));
labelsB.add(c.getString(15));
labelsB.add(c.getString(17));
Collections.shuffle(labelsA);
Collections.shuffle(labelsB);
a1.setText(labelsA.get(0));
a1.setOnClickListener(clickListener);
a2.setText(labelsA.get(1));
a2.setOnClickListener(clickListener);
a3.setText(labelsA.get(2));
a3.setOnClickListener(clickListener);
a4.setText(labelsA.get(3));
a4.setOnClickListener(clickListener);
a5.setText(labelsA.get(4));
a5.setOnClickListener(clickListener);
a6.setText(labelsA.get(5));
a6.setOnClickListener(clickListener);
a7.setText(labelsA.get(6));
a7.setOnClickListener(clickListener);
a8.setText(labelsA.get(7));
a8.setOnClickListener(clickListener);
b1.setText(labelsB.get(0));
b1.setOnClickListener(clickListener);
b2.setText(labelsB.get(1));
b2.setOnClickListener(clickListener);
b3.setText(labelsB.get(2));
b3.setOnClickListener(clickListener);
b4.setText(labelsB.get(3));
b4.setOnClickListener(clickListener);
b5.setText(labelsB.get(4));
b5.setOnClickListener(clickListener);
b6.setText(labelsB.get(5));
b6.setOnClickListener(clickListener);
b7.setText(labelsB.get(6));
b7.setOnClickListener(clickListener);
b8.setText(labelsB.get(7));
b8.setOnClickListener(clickListener);
}
finally{
mDbHelper.close();
}
我想你可能需要在使用你的應用程序之前瞭解有關SQL和數據庫的一般信息 – nicopico 2013-03-18 23:09:02
其他有用的評論?我想我在學習過程中,你爲什麼認爲我在問這個問題? – user2083882 2013-03-18 23:11:50
對於某個應用程序,您很少需要超過**一個**數據庫,所以我認爲您正在混合*數據庫*和*表*。 SQL是你如何查詢數據庫中的表。在我們能夠幫助你之前,你需要學習基礎,差距太大 – nicopico 2013-03-18 23:17:10