how to: load drawable icon with app names in android listview -
i wondering how may load drawables or icons applications along app name , activity. looked upon many examples available had no idea how implement them 1 here. if can guide me, great.
public void loadapps() { final intent main=new intent(intent.action_main, null); final packagemanager pm = getpackagemanager(); int i=0; int j=0; string tmpnick=""; if(pkg.name.size()!=0 ) {pkg.name.clear(); pkg.activity.clear(); pkg.nick.clear();} switch(checkedradiobutton) { case 0: // lauchables variant of load apps for(i=0; i<pkgextra.name.size(); i++ ) { pkg.name.add(pkgextra.name.get(i)); pkg.nick.add(pkgextra.nick.get(i)); pkg.activity.add(pkgextra.activity.get(i)); } main.addcategory(intent.category_launcher); final list<resolveinfo> launchables=pm.queryintentactivities(main, 0); for(resolveinfo launchable : launchables) { if (itemnuminhide(launchable.activityinfo.name)==-1) { pkg.name.add(launchable.activityinfo.packagename); pkg.activity.add(launchable.activityinfo.name); pkg.nick.add(launchable.activityinfo.loadlabel(pm).tostring()); } } break; case 1: final list<resolveinfo> launchables2=pm.queryintentactivities(main, 0); ) int length=0; for(resolveinfo launchable : launchables2) { string[] tmpsplit = new string[10]; //acinfo=launchable.activityinfo; tmpsplit=launchable.activityinfo.name.split("\\."); length=tmpsplit.length; pkg.name.add(launchable.activityinfo.packagename); pkg.activity.add(launchable.activityinfo.name); tmpnick=""; tmpnick=tmpsplit[1]; for(j=2; j<length; j++) { tmpnick=tmpnick + ":" + tmpsplit[j]; } pkg.nick.add(tmpnick); //pkg.nick.add(tmpsplit[length-2]+ ":" +tmpsplit[length-1]); } break; case 2: //final list<resolveinfo> launchables3=pm.queryintentactivities(main, 0); // pkg.last=pkgextra.name.size()-1; for(i=0; i<pkgextra.name.size(); i++ ) { //tmpsplit=acinfo.name.split("\\."); // length=tmpsplit.length; pkg.name.add(pkgextra.name.get(i)); pkg.nick.add(pkgextra.nick.get(i)); pkg.activity.add(pkgextra.activity.get(i)); } break; case 3: //pkg.last=pkghide.name.size()-1; for(i=0; i<pkghide.name.size(); i++ ) { //tmpsplit=acinfo.name.split("\\."); // length=tmpsplit.length; pkg.name.add(pkghide.name.get(i)); pkg.nick.add(pkghide.nick.get(i)); pkg.activity.add(pkghide.activity.get(i)); } break; } pkg.name.add(app_package_name+".menu" ); pkg.nick.add(" menu-launcher"); pkg.activity.add(app_package_name+".menu"); }
}
on android developers site / asynctaskloader.html there complete example loads apps , displays them on listview
.
if that's not enough, have created project out of here: asynctaskloader couple modifications run on android 2.x.
Comments
Post a Comment