【发布时间】:2015-03-04 07:26:46
【问题描述】:
我有一个具有public View getView(int position, View convertView, ViewGroup parent) 方法的自定义适配器。
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ObjA obj = mArr.get(position);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view;
if (convertView == null) {
view = new View(mContext);
view = inflater.inflate(R.layout.grid_view, null);
} else {
view = (View) convertView;
}
// set value into bus_stop_name textView
TextView id_label = (TextView) view.findViewById(R.id.txt_ID);
TextView direction_label = (TextView) view.findViewById(R.id.txt_Direction);
id_label.setText(obj.getId()); // Setting values in view
direction_label.setText(obj.getName());
GetTiming getTiming = new GetTiming(mContext, this, obj.getId(), view);
getTiming.execute();
return view;
}
这个 GetTiming 是从 Parse.com 获取时间的 AsyncTask。我有接口调用public void onGetTimings(ArrayList<Timing> timings, View view) 方法。
@Override
public void onGetTimings(ArrayList<Timing> timings, View view) {
TextView time = (TextView) view.findViewById(R.id.txt_time);
busRouteTime.setText("" + timings.get(0).getTime() + "");
}
此方法被多次调用。表示多个网络调用。我还有其他也使用 Parse.com 的功能。由于一次又一次地调用此方法,应用程序变慢。谁能建议其他选项来更新 listItemView 中的 textView?
【问题讨论】:
标签: java android android-listview android-asynctask listadapter