Reputation: 379
I want to list all installed applications in an expandableListView
with the corresponding icons of the applications. The list of installed applications works, but I have got no matter, how to insert the applications icons for the ListView.
Here is my code of the expandableListView
:
public class GestureAnyWhere extends ExpandableListActivity {
private ArrayList<String> elternElemente = new ArrayList<String>();
private ArrayList<Object> kindElemente = new ArrayList<Object>();
...
ExpandableListView liste_schritt1 = getExpandableListView ();
// Zeilenabstand bestimmen
liste_schritt1.setDividerHeight ( 10 );
// Pfeil an der Seite rechts anzeigen lassen durch setGroupIndicator
// liste_schritt1.setGroupIndicator ( getResources().getDrawable(R.drawable.expandiconempty) );
liste_schritt1.setClickable ( true );
elternElementTexte ();
kindElementTexte();
MyExpandableAdapter adapter = new MyExpandableAdapter(elternElemente, kindElemente);
adapter.setInflater ( ( LayoutInflater ) getSystemService ( Context.LAYOUT_INFLATER_SERVICE ), this );
liste_schritt1.setAdapter ( adapter );
liste_schritt1.setOnChildClickListener ( this );
...
private void elternElementTexte(){
elternElemente.add("Anwendung starten");
}
private void kindElementTexte(){
ArrayList<String> kinder = new ArrayList<String>();
final PackageManager pm = getPackageManager();
List<ApplicationInfo > packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
String packetName = null;
for (ApplicationInfo packageInfo : packages) {
packetName = packageInfo.packageName;
kinder.add(packetName);
}
kindElemente.add(kinder);
}
Thanks a lot for helping
Upvotes: 0
Views: 44
Reputation: 1007624
Call loadIcon()
on the ApplicationInfo
, passing in your PackageManager
as a parameter, to get the Drawable
to put into the ImageView
.
Upvotes: 1