在代码中,我将新值传递给同一个活动(OneActivity),但是当我单击按钮时,它似乎打开了一个新活动(刷新屏幕)。如何修改下面的代码以维护 Activity 而不是在单击按钮时刷新它?
final Button fruit_q = (Button) findViewById(R.id.fruit_q);
fruit_q.setOnClickListener(new OnClickListener() //Next step
{
public void onClick(View v)
{
Intent i = new Intent(getApplicationContext(), OneActivity.class);
if(position != 35) //35 is end of index in gridview array
{
// passing array index
String name = getResources().getResourceEntryName(imageAdapter.mThumbIds[position+1]);
i.putExtra("image_name", name);
i.putExtra("id", position+1);
i.putExtra("rememberID_frist", firstTimeID_1);
i.putExtra("rememberID_second", position+1);
whatfruit.stop();
correctAnswer.stop();
}
else // ber sin chea answer dol index 35 hery jang back to index 0
{
// passing array index
//String name = getResources().getResourceEntryName(imageAdapter.mThumbIds[position+1]);
i.putExtra("image_name", "apple");
i.putExtra("id", 0);
i.putExtra("rememberID_frist", firstTimeID_1);
i.putExtra("rememberID_second", 0);
whatfruit.stop();
}
startActivity(i);
}
});
谢谢!