The first item of the listview get lost after screen fills with rows at time of scroll needed. Till 7 or 8th item the first row is visible but after 8th row it gets missing. After scroll starts everything gets normal except the first row lost. Below is the code looking for help.
public class ProfileArrayAdapter extends ArrayAdapter<Results> {
private Context mContext;
public ProfileArrayAdapter(Context context, int resource, ArrayList<Results> resultsArrayList) {
super(context, resource, resultsArrayList);
this.mContext =context;
}
static class ViewHolder {
TextView questionIdView;
TextView testTypeView;
TextView correctAnswerCountView;
TextView wrongAnswerCountView;
TextView emptyAnswerCountView;
TextView testDateView;
TextView successRateView;
}
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
View convertView = view;
ViewHolder viewHolder;
Results results = getItem(position);
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.overall_summary_template, viewGroup, false);
viewHolder = new ViewHolder();
viewHolder.questionIdView = (TextView) convertView.findViewById(R.id.overall_question_id);
viewHolder.testTypeView = (TextView) convertView.findViewById(R.id.overall_test_type);
viewHolder.correctAnswerCountView = (TextView) convertView.findViewById(R.id.overall_correct_answer);
viewHolder.wrongAnswerCountView = (TextView) convertView.findViewById(R.id.overall_wrong_answer);
viewHolder.emptyAnswerCountView = (TextView) convertView.findViewById(R.id.overall_empty_answer);
viewHolder.testDateView = (TextView) convertView.findViewById(R.id.overall_test_date);
viewHolder.successRateView = (TextView) convertView.findViewById(R.id.success_rate);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
String testId = " #" + results.getItemTestIdString();
viewHolder.questionIdView.setText(testId);
String testType = results.getItemTestType();
viewHolder.testTypeView.setText(testType);
String testDate = results.getItemTestDate();
viewHolder.testDateView.setText(testDate);
String wrongOnesText = mContext.getString(R.string.wrong_summary);
String falseOnes = wrongOnesText + String.valueOf(results.getItemNumberOfFalseAnswers());
viewHolder.wrongAnswerCountView.setText(falseOnes);
String emptyOnesText = mContext.getString(R.string.empty_summary);
String emptyOnes = emptyOnesText + String.valueOf(results.getItemNumberOfEmptyAnswers());
viewHolder.emptyAnswerCountView.setText(emptyOnes);
String correctOnesText = mContext.getString(R.string.correct_summary);
String correctOnes = correctOnesText + String.valueOf(results.getItemNumberOfCorrectAnswers());
viewHolder.correctAnswerCountView.setText(correctOnes);
String successRate = "% " + results.getItemSuccessRate();
viewHolder.successRateView.setText(successRate);
return convertView;
}
}
Override two methods getItemId()
and getItemViewType()
in the adapter itself ..and make both of them return the default return statement (position) and check.