我經歷了很多帖子的屏幕方向。 但我的情況有點不同。我的ListView有自定義的行佈局。使用AsyncTask從Internet上加載ImageView位圖。我想要的是,是否可以保存我的ListView或整個ListView的ArrayAdapter,以便在方向屏幕更改時保存其狀態。保存我的ListView的狀態爲屏幕方向
請推薦一些帖子或者如果發佈了一些代碼,這將是非常有用的。
public View getView(int position, View convertView, ViewGroup parent) {
final Contents entry = contentList.get(position);
View row = convertView;
LayoutInflater infltr = null;
if (row == null) {
infltr = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.highlight_contents_layout,
parent, false);
}
ImageView imgViewImage = (ImageView) row
.findViewById(R.id.imgView_Image);
if (imgViewImage.getTag() == null) {
new DownloadImage(imgViewImage, entry).execute(); //Async Task to download Image
}
}
return row;
}
和的onCreate我有一個函數調用來填充列表的函數調用:
init(){
listContent = (ListView) findViewById(R.id.listview); //vairable declared at top of my class;
contentlist = new ArrayList<Contents>(); //Variable Declared at top of class;
//... Populated the contenlist... in here
//..
//..
adapter = new ListAdapter(getApplicationContext(),
R.layout._contents_layout, contentList,
thumb_image_bytes);
listContent.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
這不是由google推薦 – 2014-07-10 15:02:16