public class l extends Activity implements OnItemClickListener,OnItemLongClickListener,Comparator<a>
{
GridView g;
int w,h,p;
List<a> a=new ArrayList<a>();
//点击事件
@Override
public void onItemClick(AdapterView<?> av, View v, int i, long l) {
startActivity(new Intent().setComponent(new ComponentName(a.get(i).p(), a.get(i).c())));
}
//长按事件,可去除
@Override
public boolean onItemLongClick(AdapterView<?> av, View v, int i, long l)
{
String s=a.get(i).p();
Intent it = new Intent();
it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (Build.VERSION.SDK_INT >= 9) {
it.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
it.setData(Uri.fromParts("package", s, null));
} else if (Build.VERSION.SDK_INT <= 8) {
it.setAction(Intent.ACTION_VIEW);
it.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
it.putExtra("com.android.settings.ApplicationPkgName", s);
}
startActivity(it);
return true;
}
//排序规则
@Override
public int compare(a a, a b)
{
Collator c = Collator.getInstance(java.util.Locale.CHINA);
if (c.compare(a.t(), b.t())>0){
return 1;
}else if (c.compare(a.t(), b.t())<0){
return -1;
}
return 0;
}
//重写退出事件,本程序为主桌面时,可防止误退导致手机出错
@Override
public void finish(){}
//桌面图标的主要内容
class b extends BaseAdapter {
@Override
public int getCount(){return a.size();}
@Override
public Object getItem(int i){return a.get(i);}
@Override
public long getItemId(int i){return i;}
@Override
public View getView(int id, View v, ViewGroup vg) {