정수 (id)를 listview (클릭했을 때)에서 TheEndActivity.java로 전달하려고합니다. 하지만 내 코드는 정수를 올바르게 검색 할 수 없다.listview에서 다른 액티비티로 정수를 전달합니다.
UsernameList.java는
public void onListItemClick(ListView parent, View view, int position, long id) {
Intent i = new Intent(this, TheEndActivity.class);
i.putExtra("int", (int)id);
Log.e(LOG_TAG, "id value "+id);
startActivity(i);
Intent intent = new Intent(UsernameList.this, QuizAppActivity.class);
startActivity(intent);
}
TheEndActivity.java (내가 여기에 정수를 전달해야 그 클래스. 그것은에서 onCreate 메소드 내에서 생성된다)
(이 정수가 나오는 클래스)Intent i = getIntent();
final int number = i.getIntExtra("int", -1);
와 나는 (작업이 TheEndActivity.java에서 이루어집니다)
finishBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
helper.insertMark(currentGame.getRight(), number);
Log.e(LOG_TAG, "id value: " + number);
Intent i = new Intent(TheEndActivity.this, MainMenu.class);
startActivity(i);
}
});
데이터베이스에 저장 정수 (ID)를 사용합니다 16,
이 문제는 내가이 개 활동이라고
해결. 고마워요
왜 'startActivity()'를 두 번 호출합니까? – Dalmas
'id' 또는'position'을 원하십니까? – Pawan
'int' 대신'long'을 전달하지 않으시겠습니까? –