栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

模仿新浪微博的listview更多分页按钮(原创)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

模仿新浪微博的listview更多分页按钮(原创)

因为百事查需要,需要制作这样的更多分页按钮,因为感觉新浪微博的更多分页按钮比较好,就尝试做了一下。
1、首先需要考虑布局,就是footer的布局,如下:

android:layout_height="wrap_content" android:focusable="true"

xmlns:android="https://schemas.android.com/apk/res/android"

android:background="@drawable/loadmore" android:layout_centerVertical="true"

android:layout_centerHorizontal="true">

android:orientation="vertical" android:layout_width="fill_parent">

android:layout_height="2.0dip" android:layout_width="fill_parent" />

   android:orientation="horizontal" android:layout_centerVertical="true"

android:layout_width="fill_parent" android:layout_height="60dip">

android:gravity="center" android:id="@id/tv_msg" android:text="更多"

android:layout_width="fill_parent" android:layout_height="wrap_content"/>

android:layout_gravity="center" android:orientation="horizontal"

android:id="@+id/llloading" android:layout_width="fill_parent">

android:id="@id/footprogress" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:indeterminateBehavior="repeat"

/>

android:padding="2.0px" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="读取中" />


期中上面的一个@drawable/loadmore是一个选择器如下

xmlns:android="https://schemas.android.com/apk/res/android"

>

        android:state_pressed="false"

android:drawable="@drawable/listview_gradient"

>

android:state_pressed="true"

android:drawable="@drawable/list_selector_background_pressed"

>

其中list_selector_background_pressed系统带的一个按钮在listview源代码中可以找到或sdk中也有

2、同时加载footer布局

                list_footer = (LinearLayout)LayoutInflater.from(FansActivity.this).inflate(R.layout.sinalist_footer, null);

tv_msg = (TextView)list_footer.findViewById(R.id.tv_msg);

loading = (LinearLayout)list_footer.findViewById(R.id.llloading);

//btloadmore = (Button)list_footer.findViewById(R.id.loadMoreButton);

listView = getListView();

top_panel = (View)findViewById(R.id.fans_top);

top_btn_left = (Button)top_panel.findViewById(R.id.top_btn_left);

top_btn_right = (Button)top_panel.findViewById(R.id.top_btn_right);

top_title = (TextView)top_panel.findViewById(R.id.top_title);

listView.addFooterView(list_footer, null, false);//利用FooterVIew分页动态加载,参数false是不让选择
3、list_footer中增加按钮事件如下

list_footer.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

try {

// Toast.makeText(FansActivity.this, "我将消失了",

// Toast.LENGTH_SHORT).show();

//list_footer.setBackgroundColor(Color.YELLOW);

//list_footer.invalidate();

new FansThread().start();

//tv_msg.setEnabled(false);

tv_msg.setVisibility(View.GONE);// 隐藏更多提示的TextView

loading.setVisibility(View.VISIBLE);// 显示最下方的进度条

} catch (Exception e) {

e.printStackTrace();

}

}

});

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/878048.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号