에서 같은 값을 반환한다. 교육 클래스 :데이터베이스에 데이터를 삽입 한 후에 데이터의 개수를 계산하고 난 연수가 텍스트 뷰에서 데이터베이스에 삽입 직후 훈련생의 수를 표시 할 3 훈련생
public void addTrainee(Trainee trainee){
// Inserting person details to the database is in separate method
trainee.storeToDB();
//Counting the number of participants
trainee.countTrainee(this.getId());
// Create the link between the trainee and the training
trainee.registerToTraining(this.getId());
// Add the trainee to the attendance list of the current training object
this.traineeArrayList.add(trainee);
}
연수생 클래스 : 다음은 내 코드입니다
public int countTrainee(int training_id) {
DatabaseHelper db = DatabaseHelper.getInstance();
String countQuery = "SELECT * FROM" + DatabaseHelper.TABLE_ATTENDANCE;
Cursor cursor = db.select(countQuery);
cursor.close();
return cursor.getCount();
}
내 활동 클래스 :
countTrainee = (TextView)findViewById(R.id.traineeCount);
countTrainee.setText(trainee.countTrainee(0));
내가 완전히 잘못했던 것을 알고있다. 하지만 누군가가이 문제를 해결할 수 있도록 도와 줄 수 있습니까? 이 코드로 무엇을하려고하는지 이해하고 싶습니다.
당신은 가까이하지 커서 다음'getCount()'를 사용할 수 있습니다! –
이 유일한 문제인가요? – user3099195
아니 ... 어디'training_id'이 사용된다? '위해, 무엇'trainee.countTrainee (this.getId())인가? 이 [tag : Android]입니까? –