0

I am creating a feature inside my Android app that will allow users to see their 6 last used apps in a gridview with only the application image. So far I have tried this:

        //Load recent used apps
    ActivityManager result = (ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE);
    ArrayList<RecentTaskInfo> apps = (ArrayList<RecentTaskInfo>) result.getRecentTasks(10, ActivityManager.RECENT_WITH_EXCLUDED);
    ArrayAdapter adapter = new ArrayAdapter(MainActivity.this,
            android.R.layout.simple_list_item_1, apps);
    recentappsGridView.setAdapter(adapter);

But this only shows a lot of text in each row and column. How can I fix this/make it happen? Please note that I am already using a ListView within the same activity with a method for its click events.

4

1 回答 1

1

创建 的子类ArrayAdapter。覆盖getView()。将您的单元格设置为图像,而不是TextView. 使用你从中得到的resolveActivityInfo()对象Intent。使用on填充您的单元格。baseIntentRecentTaskInfoActivityInfoiconActivityInfo

我没试过那个食谱,但它应该让你更接近。

于 2013-02-01T20:12:23.153 回答