正在做一个Android的课程设计,主要功能是任务管理器,需要用到ActivityManager,所以就拿这个类来当作ListView的练习了。
本次的任务是将所有正在运行的进程添加到ArrayAdapter适配器,并在ListView中显示出来。
布局文件很简单,只有一个refresh按钮和一个ListView。
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ListView
android:id="@+id/myListView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/refresh"
/>
<Button
android:id="@id/refresh"
android:layout_width="fill_parent"