点击istview的item,控制item的footer的展开与隐藏
效果如图所示,查看,下载更新,删除三个按钮在布局里面用footer包起来
<LinearLayout
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<Button
android:id="@+id/btn_display"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="@drawable/offline_button_style"
android:focusable="false"
android:text="查看"
android:textColor="@color/bg_sliding_menu" />
<Button
android:id="@+id/btn_load"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="@drawable/offline_button_style"
android:focusable="false"
android:text="暂停"
android:textColor="@color/bg_sliding_menu" />
<Button
android:id="@+id/btn_remove"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/offline_button_style"
android:focusable="false"
android:text="删除"
android:textColor="@color/bg_sliding_menu" />
</LinearLayout>
1.在adapter类里面写上改方法
/**
* 修改展开选项的位置
* @param position
*/
public void changeVisable(int position) {
if (position != mLastPosition) {
mLastPosition = position;
} else {
mLastPosition = -1;
}
notifyDataSetChanged();
}
2.在getview()方法里面写上
if (position == mLastPosition) {
itemHolder.footer.setVisibility(View.VISIBLE);
} else {
itemHolder.footer.setVisibility(View.GONE);
}
3.在listview的item点击事件里写上
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
adapter.changeVisable(position);
}
});