荒废许久的Android开发现在又重新开刀干了,发现还是很有激情坐下去的,也希望毕业之后找一份Android开发的工作吧,用博客来记录一下自己掉过的坑,这些东西不用的话,没过多久就会忘记,这不,又倒回来看ListView,揪心,以后就可以看自己博客了,就不用再百度了,啊哈哈哈哈。
先说点其它的,最近试了试Git出的编辑器Atom,跟我之前超爱的sublime长得挺像的,不过刚下好久能带文件管理,可以直接管理整个文件夹,配色看着也挺舒服的,发现一个优点就是整合了第三方包,可以直接搜索然后点install,超方便,有木有!!!
接着就是正经的了,自定义ListView其实也超简单的,自定义一个item布局,再重写适配器,然后就行了。就是这么简单,可我忘记了好几次。
首先是Activity的布局,就一个ListView就行了,中间的divider是设置listview每个item的间距,想要就要。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F3F3F3"
android:orientation="vertical" >
<ListView
android:id="@+id/listView_tab_teacher"
android:dividerHeight="3pt"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
然后是item的布局:
我这个布局有点多,可以按自己需求创建布局,自己怎么拉一个就行,设置好id就好
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"