您好我正在使用我的应用中的适配器。
updateUI()方法的内容如下:
public void updateUI() {
musicAlbumAdapter = new MusicAlbumAdapter(getActivity(),
R.layout.music_album_row_layout, storeAlbumDetails);
music_album_listview.setAdapter(musicAlbumAdapter);
music_album_listview.setSelection(savedListPosition);
/*
* LinearLayout listFooterView = (LinearLayout)inflater.inflate(
* R.layout.footer_layout, null);
*
* list.addFooterView(listFooterView);
*/
//confirm with adapter that returning the view at very first time then cancel the dialog
if(pDialog != null && pDialog.isShowing())
pDialog.cancel();
if(pDialogLazyLoading != null && pDialogLazyLoading.isShowing())
pDialogLazyLoading.cancel();
}
但在加载数据之前,ProgressDialog pDialog已关闭。该页面看起来空白几秒钟。如下图所示。
我在这里使用过ArrayAdapter:
public class MusicAlbumAdapter extends ArrayAdapter<AlbumDetails> {
private Context context;
private ArrayList<AlbumDetails> albumDetails;
/*
* private ArrayList<String> albumTitle; private ArrayList<String>
* albumMusic; private ArrayList<String> albumImage;
*/
public MusicAlbumAdapter(Context context, int resource,
ArrayList<AlbumDetails> albumDetails) {
super(context, resource, albumDetails);
this.context = context;
this.albumDetails = albumDetails;
/*
* this.albumTitle = albumTitle; this.albumMusic = albumMusic;
* this.albumImage = albumImage;
*/
// TODO Auto-generated constructor stub
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.music_album_row_layout,
parent, false);
try {
TextView music_album_title = (TextView) rowView
.findViewById(R.id.music_album_row_title);
Activity activity = (Activity) context;
music_album_title.setTypeface(FontTypefaces.getHero(activity));
music_album_title.setText(albumDetails.get(position)
.getAlbumTitle());
} catch (IndexOutOfBoundsException e) {
}
try {
TextView music_album_music = (TextView) rowView
.findViewById(R.id.music_album_row_music);
Activity activity = (Activity) context;
music_album_music.setTypeface(FontTypefaces.getHero(activity));
music_album_music.setText(albumDetails.get(position)
.getAlbumMusic());
} catch (IndexOutOfBoundsException e) {
}
try {
ImageView music_album_image = (ImageView) rowView
.findViewById(R.id.music_album_row_image);
Picasso.with(context)
.load(albumDetails.get(position).getAlbumImage())
.placeholder(R.drawable.rlogo) // optional
.error(R.drawable.rlogo) // optional
.into(music_album_image);
} catch (IndexOutOfBoundsException e) {
}
return rowView;
}
}