我试图在该列表中添加一个侦听器,但我不明白为什么如果您想查看其余代码,请检查将您自己的侦听器添加到列表中
public void onCreatebis(final ResolveInfo resolveInfo) {
setContentView(R.layout.main);
final Intent mainIntent=new Intent(Intent.ACTION_MAIN,null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER) ;
final PackageManager pm = getApplicationContext().getPackageManager();
final ArrayList<ResolveInfo> listP= (ArrayList<ResolveInfo>) pm.queryIntentActivities( mainIntent, 0);
final int trimLength = "com.android.".length();
ArrayList<String> maliste = new ArrayList<String>();
// Loop over each item.
for (ResolveInfo info : listP) {
// Get the (full, qualified) package name.
String packag = info.activityInfo.applicationInfo.packageName;
// Now, trim it with substring and the trim length.
String trimmed = packag.substring(trimLength);
maliste.add(trimmed);
}
ListView list = (ListView)findViewById(R.id.list);
monadaptateur adapter2 = new monadaptateur(this, maliste);
list.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Log.v("lalalala","lalala");
}
});
list.setAdapter(adapter2);
}