首页 > 代码库 > 把 Activity 改成 ListActivity继续使用 setContentView

把 Activity 改成 ListActivity继续使用 setContentView

ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list"  (or list if it‘s in code)

在Main的<listvie定义的时候,需要写一个系统知道的名字, id "@android:id/list" 。否则系统就找不到。

ListActivity中setContentView()传入的layout中必须有一个id为android:list的ListView

去掉ListView 的分割线

ListView.setDividerHeight(0);ListView.setDivider(null);

去掉ListView 或各种滚动控件的边界颜色

android:overScrollMode="never"android:fadingEdge="none"