코드 코드에서 새 값을 동일한 Activity (OneActivity)로 전달하지만 버튼을 클릭하면 새 Activity (화면 새로 고침)가 열리는 것 같습니다. 아래의 코드를 수정하여 버튼을 클릭 할 때 활동을 유지하고 새로 고치지 않으려면 어떻게해야합니까?On Button 클릭, 동일 활동의 값 유지 또는 변경
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);
}
});
고마워요!
당신이 전달하는 네 개의 값을 만듭니다
의도를 작성하고 startActivity (i)를 호출하면 활동이 새로 고쳐진다는 것은 분명히 공유 환경 설정 – Raghunandan
이 필요합니다. onClick()에서 변경할 전역 변수가 필요할 수 있습니다. –
친애하는 Valentino 님, 이미 2 시간 동안 시도했지만 여전히 솔로 션을 찾을 수 없으므로 코드에 수정 해 주실 수 있습니까? – user1731690