カスタム アダプターを備えた ListView があります。すべての行には、特定の制約の下でのみ表示される ImageView があります。問題は、最初の行にこの ImageView が表示されている場合、最後の行にも表示され、その逆もあることです。
getView()
これが私のアダプターのコードです。
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.row_idea, null);
}
Idea idea = mIdeas.get(position);
if (idea != null) {
ImageView imgAlarm = (ImageView) view
.findViewById(R.id.imgAlarm_rowIdea);
if (idea.getTimeReminder() != null)
imgAlarm.setVisibility(ImageView.VISIBLE);
TextView lblTitle = (TextView) view
.findViewById(R.id.lblTitle_rowIdea);
lblTitle.setText(idea.getTitle());
TextView lblDescription = (TextView) view
.findViewById(R.id.lblDescription_rowIdea);
lblDescription.setText(idea.getDescription());
}
return view;
}
mIdeas
にArrayList
表示するすべてのデータを含むListView
です。
imgAlarm
私が上で言ったImageView
ことです。