在这个例子中,如何在getView(int position,View convertView,ViewGroup parent)中更改convertView

时间:2015-07-12 16:56:00

标签: android android-adapter

你可以告诉我在这个例子中Character将如何改变:

List

我想知道HashSet& convertView& @Override public View getView(int position, View convertView, ViewGroup parent) { // If we weren't given a view, inflate one if (convertView == null) { convertView = getActivity().getLayoutInflater().inflate(R.layout.list_item_crime, null); } // Configure the view for this Crime Crime c = getItem(position); TextView titleTextView = (TextView)convertView.findViewById(R.id.crime_list_item_titleTextView); titleTextView.setText(c.getTitle()); TextView dateTextView = (TextView)convertView.findViewById(R.id.crime_list_item_dateTextView); dateTextView.setText(c.getDate().toString()); CheckBox solvedCheckBox = (CheckBox)convertView.findViewById(R.id.crime_list_item_solvedCheckBox); solvedCheckBox.setChecked(c.isSolved()); return convertView; } 影响convertView ??? 或者在方法结束时返回的titleTextViewdataTextViewsolvedCheckBox& convertView& convertView = getActivity().getLayoutInflater().inflate(R.layout.list_item_crime, null);titleTextView ???

中没有改变任何内容

1 个答案:

答案 0 :(得分:1)

 if (convertView == null) {
convertView = getActivity().getLayoutInflater().inflate(R.layout.list_item_crime, null);

}

这是convertView的初始化,你只需要第一次这样做,然后第二次不需要它和titleTextView& dataTextView& solveCheckBox不会影响convertView