我已经实现了一个列表视图,其中包含来自 url 的解析数据,我为此使用了惰性适配器。现在我希望列表包含拉动刷新属性,但我的问题是我无法找到正确的方法来实现这一点,请帮助
我的列表视图 XML 是:-
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/upBar" >
<ListView
android:id="@+id/latestList"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:cacheColorHint="#00000000"
android:listSelector="#00000000"
android:padding="7dp"
android:scrollbars="none" />
</RelativeLayout>
我的懒惰适配器是这样的:-
public class LazyAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<String> movieThumbnail;
private ArrayList<String> movieText;
private static LayoutInflater inflater=null;
static File cacheDir;
ImageLoader imageloader = new ImageLoader(activity);
public LazyAdapter(Activity a, ArrayList<String> movieThumbnail, ArrayList<String> movieText) {
activity = a;
/*data=d;*/
this.movieThumbnail = movieThumbnail;
this.movieText = movieText;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return movieText.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.listrow, null);
TextView text=(TextView)vi.findViewById(R.id.rowListTextView);
ImageView image=(ImageView)vi.findViewById(R.id.movieImage);
text.setText(movieText.get(position));
imageloader.DisplayImage(movieThumbnail.get(position), image);
return vi;
}
public void clear(){
imageloader.clearCache();
}
我正在像这样在 AsyncTask 中设置惰性适配器:-
@Override protected void onPostExecute(ArrayList<HashMap<String, String>> result) {
lazyAdapter = new LazyAdapter(context, imgLinks, latestData);
listView.setAdapter(lazyAdapter);}