【发布时间】:2014-03-01 14:26:33
【问题描述】:
我有一个列表视图,它显示设备上所有已安装应用程序的列表。我无法找到一种方法来启动一个单独的屏幕,其中包含基于列表视图中所选项目的信息。
例如:单击列表视图中的“Facebook”将打开一个屏幕,其中包含我输入的有关 Facebook 的信息。
代码
public class ListApplications extends Activity {
private ListView lView;
private ArrayList results = new ArrayList();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_applications);
lView = (ListView) findViewById(R.id.listview);
PackageManager pm = this.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);
for (ResolveInfo rInfo : list) {
results.add(rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
Log.w("Installed Applications", rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
}
lView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, results));
}
【问题讨论】:
标签: android listview android-listview android-activity