我的设备中android应用程序的可折叠列表?
从这个代码开始我的设备中android应用程序的可折叠列表?,android,button,android-listview,collapsable,Android,Button,Android Listview,Collapsable,从这个代码开始 class PackageInfoData{ private String appname = ""; private String pname = ""; private String versionName = ""; private int versionCode = 0; private Drawable icon; } private void getInstalledPackages() { ArrayList<
class PackageInfoData{
private String appname = "";
private String pname = "";
private String versionName = "";
private int versionCode = 0;
private Drawable icon;
}
private void getInstalledPackages() {
ArrayList<PackageInfoData> installedApps = getInstalledApps(false); /* false = no system packages */
for (int i=0; i<installedApps.size(); i++) {
Log.i("Instlled app","APp Name:"+installedApps.get(i).appname+"package:"+installedApps.get(i).pname);
}
return installedApps ;
}
private ArrayList<PackageInfoData> getInstalledApps(boolean getSysPackages) {
ArrayList<PackageInfoData> res = new ArrayList<PackageInfoData>();
List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
for(int i=0;i<packs.size();i++) {
PackageInfo p = packs.get(i);
if ((!getSysPackages) && (p.versionName == null)) {
continue ;
}
PackageInfoDatanewInfo = new PackageInfoData();
newInfo.appname = p.applicationInfo.loadLabel(getPackageManager()).toString();
newInfo.pname = p.packageName;
newInfo.versionName = p.versionName;
newInfo.versionCode = p.versionCode;
newInfo.icon = p.applicationInfo.loadIcon(getPackageManager());
res.add(newInfo);
}
return res;
}
类PackageInfo数据{
私有字符串appname=“”;
私有字符串pname=“”;
私有字符串versionName=“”;
私有int versionCode=0;
私人绘图图标;
}
私有void getInstalledPackages(){
ArrayList installedApps=getInstalledApps(false);/*false=无系统包*/
对于(int i=0;我喜欢ExpandableListView,那么?是这样的。但是我的代码是说..你已经有了列表中的数据
。你应该能够按照任何教程将其更改为ExpandableListView
。首先,你可以搜索其他内容:你可以在某处添加一个按钮,然后隐藏lis使用此list.setVisibility(View.GONE)
单击按钮。或者,如果您使用的是ListFragment或ListActivity,则可以使用setListShowed()
函数