我正在做一个测验应用程序,其中有 Act1 和 Act2。Act1 显示要选择的每个问题答案的视图。
public class ACT1 extends Activity
{
EditText question=null;
RadioGroup choices = null;
-------
------
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.question);
/* //---get the Bundle object passed in---
Bundle bundle = getIntent().getExtras();
//---get the data using the getInt() method---
int qId = bundle.getInt("questionIndex");
//不知道在这里做什么
question = (EditText) findViewById(R.id.question);
RadioGroup questionLayout = (RadioGroup)findViewById(R.id.answers);
------
this.getQuestionView(questionNo);
FrameLayout quizLayout = (FrameLayout) findViewById(R.id.quizLayout);
quizLayout.setVisibility(android.view.View.VISIBLE);
}
在 getQuestionView() 方法中,用于获取问题和答案的其余代码下一个提交按钮一切都在那里。
private void getQuestionView(questionNo)
{
------
------
//next and previous buttons OnClicklisteners
------
private OnClickListener finishListener = new OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent(Act1.this,Act2.class);
}
}
Act2 显示结果视图,其中包括问题链接表。单击问题链接时,应显示来自 Act1 的相应问题视图,单击后退按钮将返回到 Act2。我是android新手,所以请大家帮忙。public class Act2 extends Activity { -------- ------- TableLayout questionsTable;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.result);
int totalQues = Act1.getQuestions().length;
questionsTable =(TableLayout)findViewById(R.id.questions);
-------
-------
for(int i=0;i<totalQues;i++)
{
------
--------
TableRow tr = new TableRow(this);
TextView queText = new TextView(this);
tr.addView(queText,LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT);
tr.setClickable(true);
tr.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(this,Act1.class);
//---use a Bundle object to add new key/values pairs---
Bundle extras = new Bundle();
//here i wanna check whether 2nd question is displaying
extras.putInt("questionIndex",2 );
//---attach the Bundle object to the Intent object---
intent.putExtras(extras);
startActivity(intent);
}
});
提前致谢。