public class MyMainActivity extends ListActivity {
int x;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loadApps();
}
private void loadApps() {
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> mApps = getPackageManager().queryIntentActivities(
mainIntent, 0);
ListView listView = getListView();
listView.setAdapter(new AppsAdapter(this, mApps));
}
public class AppsAdapter extends BaseAdapter {
private LayoutInflater inflater;
private List<ResolveInfo> mApps;
public AppsAdapter(Context context, List<ResolveInfo> mApps) {
this.inflater = LayoutInflater.from(context);
this.mApps = mApps;
}
class ViewHandler {
TextView textLable;
ImageView iconImage;
Button buttn;
}
public View getView(final int position, View convertView,
ViewGroup parent) {
final ViewHandler Handler;
if (convertView == null) {
convertView = inflater.inflate(R.layout.customlist, null);
Handler = new ViewHandler();
Handler.textLable = (TextView) convertView
.findViewById(R.id.TV);
Handler.iconImage = (ImageView) convertView
.findViewById(R.id.IV);
Handler.buttn = (Button) convertView.findViewById(R.id.buttonx);
convertView.setTag(Handler);
} else {
Handler = (ViewHandler) convertView.getTag();
}
ResolveInfo info = this.mApps.get(position);
Handler.iconImage.setImageDrawable(info
.loadIcon(getPackageManager()));
Handler.textLable.setText(info.loadLabel(getPackageManager()));
Handler.buttn.setOnClickListener(new OnClickListener() {
boolean isClicked = false;
@Override
public void onClick(View v) {
if (isClicked == false) {
Handler.buttn.setBackgroundResource(R.drawable.locker);
Toast.makeText(getApplicationContext(), "" + position,
Toast.LENGTH_SHORT).show();
isClicked = true;
} else {
Handler.buttn
.setBackgroundResource(R.drawable.unlocked);
isClicked = false;
}
}
});
return convertView;
}
public final int getCount() {
return mApps.size();
}
public final Object getItem(int position) {
return mApps.get(position);
}
public final long getItemId(int position) {
return position;
}
}
}
如何从菜单中的所有应用程序中隐藏一个应用程序?如果有人想隐藏他或她将使用我的应用程序的应用程序,我只想为应用程序隐藏、安全或个人原因创建一个应用程序。这就是为什么我想知道如何隐藏应用程序。