2
朋友,Android的可擴展列表組的TextView隨機更換
我有擴展列表一個問題 - 首次列表組繪製正確,(各textViews文本會被替換,如3的9)但是當任何組被點擊時,另一個組(隨機)的textView被替換,而不是原始的mm。
應該做些什麼來防止這種情況?
這裏是適配器類:
public class InterestListAdapter extends BaseExpandableListAdapter
{
...
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)
{
if (convertView == null)
{
convertView = LayoutInflater.from(_context).inflate(R.layout.activity_interest_list_group, parent, false);
}
try
{
HashMap<String, String> interest = this._listDataHeader.get(String.valueOf(groupPosition));
String interestId = interest.get("interest_id");
String interestName = interest.get("interest_name");
JSONObject interestsTree = new JSONObject(library.loadString(_context, "userInterestsTree"));
TextView listGroupName = (TextView) convertView.findViewById(R.id.interest_list_group_name);
listGroupName.setText(interestName);
if (this._listDataChild.containsKey(String.valueOf(interestId)))
{
String subinterestAll = String.valueOf(this._listDataChild.get(String.valueOf(interestId)).size());
if (interestsTree.has(interestId))
{
String subinterestChecked = interestsTree.getString(interestId);
TextView subinterestText = (TextView) convertView.findViewById(R.id.interest_list_group_selected);
subinterestText.setText(subinterestChecked + " of " + subinterestAll);
}
}
}
catch (Exception e)
{
Log.e("error", Log.getStackTraceString(e));
}
return convertView;
}
}