@Override protected void initData() { super.initData(); final File folder = FileUtils.getSaveFolder("KJFrameSkin"); String[] filesPath = folder.list(); datas = new ArrayList<PluginBean>(); for (int i = 0; i < filesPath.length; i++) { String apkPath = folder.getAbsolutePath() + File.separator + filesPath[i]; PluginBean data = new PluginBean(); try { data.setIcon(CJTool.getAppIcon(aty, apkPath)); data.setName(CJTool.getAppName(aty, apkPath).toString()); data.setPath(apkPath); datas.add(data); // 如果出错就不添加了 } catch (NameNotFoundException e) { } } }
@Override protected void initWidget(View parentView) { super.initWidget(parentView); if (!datas.isEmpty()) { text.setVisibility(View.GONE); } list.setAdapter(new PluginAdapter()); list.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { try { // 调用插件资源中名为的R.drawable.bg的图片 // 唯一需要注意的就是插件项目的manifest标签下加入android:sharedUserId="org.kymjs.aframe.plugin" // (这里就不给出项目了,因为本就没有代码可言) skin.setImageDrawable( CJTool.getResFromPkgName(aty, "com.example.hello").getDrawable(R.drawable.bg)); } catch (NameNotFoundException e) { // 先安装皮肤插件 SystemTool.installApk(aty, new File(datas.get(position).getPath())); } } }); }