가능한 복제를 작동하지 않습니다
How do I do a lazy load of images in ListView비트 맵
내가 비트 맵 및 텍스트와 목록보기가 있습니다. 내가 그림을 다운로드하고 그것을보고 싶을 때, 내 애플 리케이션에 나타나지 않습니다.
List<HashMap<String, Object> > aList = new ArrayList<HashMap<String, Object> >();
for(int i=0;i<ilosctalentow.size();i++){
if (ilosctalentow.get(i).indexOf("0/")==-1)
{
HashMap<String, Object> hm = new HashMap<String,Object>();
hm.put("txt", "xxx");
hm.put("cur","Currency : " + ilosctalentow.get(i));
Bitmap bmp = DownloadImage("http://www.xxx.pl/xxx/xxx/xhxuxj.png");
hm.put("flag",bmp);
aList.add(hm);
Log.i(TAG,Integer.toString(R.drawable.afghanistan));
}
}
// Keys used in Hashmap
String[] from = { "flag","txt","cur" };
// Ids of views in listview_layout
int[] to = { R.id.flag,R.id.txt,R.id.cur};
// Instantiating an adapter to store each items
// R.layout.listview_layout defines the layout of each item
SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), aList, R.layout.listview_layout, from, to);
// Getting a reference to listview of main.xml layout file
ListView listView = (ListView) findViewById(R.id.listview);
// Setting the adapter to the listView Zaraz mnie huj strzeli
listView.setAdapter(adapter);
도와주세요 : 내가 R.drawable.imagename에서 이미지를 사용하는 경우 그것은 ... 내 코드를 작동합니다!
UI 스레드에서 이미지를 다운로드 할 수 있는지 의심 스럽습니다. 백그라운드 스레드에서 이미지를 다운로드하고 다운로드가 끝나면 어댑터를 업데이트해야합니다. 또한 SimpleAdapter 클래스 대신 자신의 어댑터를 만들어야한다고 생각합니다. – vorrtex
녹색 droid로 만들 수 있습니까? – user1906882
모든 Android 버전에서 가능합니다. 다음은 유명한 질문입니다. 코드 샘플을 찾을 수 있습니다. http://stackoverflow.com/questions/541966/how-do-i-do-a-lazy-load-of-images-in-listview – vorrtex