当前位置: 首页 > news >正文

查询公司蔡甸seo排名公司

查询公司,蔡甸seo排名公司,网站建设com网站,哈尔滨市建设委员会网站今天带来一篇实现QQ侧滑删除以及下拉刷新上拉加载的博客,前段时间在我的项目当中有个模块就是实现类似于qq侧滑上来刷新的效果,刚开始没啥思路,后来看到了一个用的比较普遍的一个开源控件,Swipelayout来实现侧滑删除,本…

      今天带来一篇实现QQ侧滑删除以及下拉刷新上拉加载的博客,前段时间在我的项目当中有个模块就是实现类似于qq侧滑上来刷新的效果,刚开始没啥思路,后来看到了一个用的比较普遍的一个开源控件,Swipelayout来实现侧滑删除,本是想通过XListView来实现下拉刷新上啦加载的,但是XListView控件还有一些问题比较突出,比如当我们的列表数据没有充满这个屏幕时,此时如果我们触发上啦刷新这个动作,会导致FooterView的高度增加,影响用户体验,甚至你在短时间内进行多次上啦刷新的动作,会导致数据重复加载,所以我使用PulToRefreshListView(当然你也可以用RecyClerView来代替),首先我们看一张实现的效果图,毕竟眼见为实吗,待会再上代码。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(应该录个动态图的,这样效果更好点,讲究点看图片不太整齐,看代码就行。。。)

要想实现这个功能,首先你的去下载这个控件的相关源码,把引入到自己的项目当中即可,这个功能最主要的代码在器Adapter中,至于添加数据等这些操作,我就不贴代码展示了,下面我们来看看如何实现这个功能。

package com.info.mettingapp.adapter;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;import com.info.mettingapp.R;
import com.info.mettingapp.model.MessageCenterModel;
import com.info.mettingapp.weight.CustomExitDialog;
import com.info.mettingapp.weight.SimpleSwipeListener;
import com.info.mettingapp.weight.SwipeLayout;
import java.util.List;/**** Created by joe.xiang on 2016/3/8.*/
public class SwipeMessageAdapter extends  BaseSwipeAdapter {/** 定义变量*/private Context mContent;private LayoutInflater mInflater;private List<MessageCenterModel> listModels;private View messageView = null;/** 初始化变量*/public SwipeMessageAdapter(Context context){this.mContent = context;mInflater = LayoutInflater.from(mContent);}/***  数据源* @param lists*/public void setMessageDate(List<MessageCenterModel> lists){this.listModels = lists;notifyDataSetChanged();}@Overridepublic int getSwipeLayoutResourceId(int position) {return  R.id.swipe;}@Overridepublic View generateView(final  int position, ViewGroup parent) {messageView = mInflater.inflate(R.layout.activity_message_item,parent,false);final SwipeLayout swipeLayout = (SwipeLayout) messageView.findViewById(getSwipeLayoutResourceId(position));// 当隐藏的删除menu被打开的时候的回调函数swipeLayout.addSwipeListener(new SimpleSwipeListener() {@Overridepublic void onOpen(SwipeLayout layout) {Toast.makeText(mContent, "Open", Toast.LENGTH_SHORT).show();}});// 双击的回调函数
             swipeLayout.setOnDoubleClickListener(new SwipeLayout.DoubleClickListener() {@Overridepublic void onDoubleClick(SwipeLayout layout,boolean surface) {Toast.makeText(mContent, "DoubleClick",Toast.LENGTH_SHORT).show();}});// 添加删除布局的点击事件messageView.findViewById(R.id.ll_menu).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View arg0) {Toast.makeText(mContent, "delete", Toast.LENGTH_SHORT).show();CustomExitDialog dialog = new CustomExitDialog(mContent,R.style.customExitDailogStyle,R.layout.custom_exit_dialog,SwipeMessageAdapter.this,listModels,position,swipeLayout);dialog.show();}});return messageView;}@Overridepublic void fillValues(int position, View convertView) {MessageHolder holder = null;if(convertView!=null){holder = new MessageHolder();holder.messageView = (ImageView)convertView.findViewById(R.id.message_image);holder.messageTitle = (TextView)convertView.findViewById(R.id.mesage_tixing);holder.messageContent = (TextView)convertView.findViewById(R.id.mesage_content);holder.messageDate = (TextView)convertView.findViewById(R.id.mesage_date);}holder.messageView.setImageResource(listModels.get(position).messageImage);holder.messageTitle.setText(listModels.get(position).messageTitle);holder.messageContent.setText(listModels.get(position).messageContent);holder.messageDate.setText(listModels.get(position).messsageDate);}@Overridepublic int getCount() {Log.i("MessageActivity", listModels.size() + "=======listModels");return listModels.size();}@Overridepublic Object getItem(int position) {return listModels.get(position);}@Overridepublic long getItemId(int position) {return position;}public void CreateDialog(final  SwipeLayout swipeLayout,final int position){AlertDialog.Builder builder = new AlertDialog.Builder(mContent);builder.setMessage("确认删除这条信息");builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {listModels.remove(position);notifyDataSetChanged();// 点击完成之后,关闭删除menu
                swipeLayout.close();}});builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {dialog.dismiss();// 点击完成之后,关闭删除menu
                swipeLayout.close();}});builder.create().show();}public static class MessageHolder {ImageView messageView;TextView messageTitle;TextView messageContent;TextView messageDate;}
}

   1、首先我们的Adapter要继承BaseSwipeAdapter,来重写他提供的方法,比如

  public int getSwipeLayoutResourceId(int position) {return  R.id.swipe;}
一定返回R.id.swipe,不然找不到你当前的Item资源
2、messageView = mInflater.inflate(R.layout.activity_message_item,parent,false);
在这里并不需要对messageView做null判断
3、Item中的控件或者布局一定要用
<com.info.mettingapp.weight.SwipeLayout
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent" >
做外层包装。
4、Item的删除就是根据当前的位置来从集合当中移除,然后通知ListView发生改变

以上就是对SwipeLayout的使用上面所需注意的地方,下次我们一起看看侧滑实现的原理,这样你就更好理解,这篇博客就不在讲解侧滑原理(下片整理)








转载于:https://www.cnblogs.com/xianglinglong/p/5306232.html

http://www.lbrq.cn/news/2623213.html

相关文章:

  • kol营销重庆seo排名方法
  • 网站建设从入门到精通 网盘福州seo网络推广
  • 营销型网站可以吗0元入驻的电商平台
  • 武汉网站优化方案经典软文文案
  • 创建网站大约多少钱2018新东方一对一辅导价格
  • wordpress首页怎么打开很慢如何优化网络速度
  • 德州做网站优化如何找友情链接
  • 网站企业模板微信引流推广怎么做
  • 3g网站跳转google关键词
  • 麦田 网站建设推广自己的网站
  • 商务网站建设与维护流程百度指数趋势
  • 大兴智能网站建设哪家好seo客服
  • 武汉网站制作在线百度推广关键词多少合适
  • 成都网站制作电话百度企业推广
  • 开发软件和做网站的区别怎么创建网站免费建立个人网站
  • 关于网站建设的新闻汕头网站设计公司
  • 延安做网站电话网络营销的渠道
  • 学校网站进不去怎么办全国新冠疫苗接种率
  • 网站开发 手机 电脑seo网站关键词排名软件
  • 万州官方网关键词优化排名软件推荐
  • 网站域名怎么修改seo排名优化培训价格
  • 国外h5网站模板下载可靠的网站优化
  • 万网 做网站百度导航2023年最新版
  • 这几年做哪个网站致富西安百度爱采购推广
  • 网站建设服务开发全国最好的广告公司加盟
  • 家政网站建设方案深圳英文网站推广
  • 三大门户网站哪家做的最好seo1搬到哪里去了
  • 一个虚拟主机可以做两个网站吧网站查询ip地址
  • 自己创业做网站网页优化方案
  • 电子商务网站建设特色公司怎么在网上推广
  • 哈希表——指针数组与单向链表的结合
  • npm 与 npx 区别详解。以及mcp中npx加载原理。
  • 【感知机】感知机(perceptron)学习策略
  • Linux---第二天---基础指令
  • 【C语言】文件操作全解析
  • C语言的数组与字符串练习题1