配列 menuItems を確認しましたが、問題ないように見えますが、次のコードに問題があります。開始すると問題ないように見えますが、スクロールを開始すると、めちゃくちゃになり、アイテムがリストの一番上に置かれ、アイテムが複製されます....それはただ変です
public class ScoresAdapter extends BaseAdapter {
private MainActivity activity;
private ScoreItem[] menuItems;
private static LayoutInflater inflater=null;
ImageDownloader downloader;
public ScoresAdapter(MainActivity a, ScoreItem[] scoreItems) {
activity = a;
menuItems = scoreItems;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
downloader = new ImageDownloader();
}
public int getCount() {
int teller = 0;
for(int i = 0 ; menuItems.length > i ; i++){
if(menuItems[i] != null){
teller++;
}
}
return teller;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null){
if(menuItems[position].getId() == 888){
//fav header
vi = inflater.inflate(R.layout.scoresheaderfavoriet, null);
}else if(menuItems[position].getId() == 999){
//overige header
vi = inflater.inflate(R.layout.scoresheaderoverig, null);
}else{
if(menuItems[position].getIsFav()){
vi = inflater.inflate(R.layout.scoresfavitem, null);
}else{
vi = inflater.inflate(R.layout.scoresitem, null);
}
TextView text2=(TextView)vi.findViewById(R.id.position);
text2.setText(""+ menuItems[position].getPosition());
TextView text=(TextView)vi.findViewById(R.id.name);
text.setText(menuItems[position].getFirstName() + " " + menuItems[position].getLastName().toUpperCase());
TextView text5=(TextView)vi.findViewById(R.id.country);
text5.setText(""+ menuItems[position].getCountry());
TextView text3=(TextView)vi.findViewById(R.id.score);
text3.setText(""+ menuItems[position].getScore());
TextView text8=(TextView)vi.findViewById(R.id.hole);
text8.setText(""+ menuItems[position].getHole());
vi.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), SpelerView.class);
intent.putExtra("id", menuItems[position].getId());
v.getContext().startActivity(intent);
activity.sluitAlleMenus();
}
});
}
}
return vi;
}
}