画面の向きについて多くの投稿を行いました。しかし、私のシナリオは少し異なります。私の ListView にはカスタムの行レイアウトがあります。ImageView ビットマップが AsyncTask を使用してインターネットから読み込まれます。私が望むのは、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();
}