PopupWindow+RecyclerView实现上下滑动框功能-创新互联
本文实例为大家分享了PopupWindow+RecyclerView实现上下滑动框功能的具体代码,供大家参考,具体内容如下
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:国际域名空间、虚拟空间、营销软件、网站建设、澄迈网站维护、网站推广。1.新建一个适配器继承自RecyclerView.Adapter
package aud.hik.com.audiorecordtool; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.List; public class FileListAdapter extends RecyclerView.Adapter{ private final String TAG = "FileListAdapter"; private List mFileList = null; private OnItemClickListener mOnItemClickListener = null; static class ViewHolder extends RecyclerView.ViewHolder{ TextView fileNameView; public ViewHolder(View view) { super(view); fileNameView = (TextView) view.findViewById(R.id.file_name); } } public FileListAdapter(List fileList) { this.mFileList = fileList; } //加载item 的布局 创建ViewHolder实例 @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item,parent,false);//加载view布局文件 ViewHolder holder = new ViewHolder(view); return holder; } //对RecyclerView子项数据进行赋值 @Override public void onBindViewHolder(ViewHolder holder, int position) { if(null == holder) { MyLog.LOGE(TAG,"Holder is null"); return; } final String fileName= mFileList.get(position); MyLog.LOGI(TAG,"filename = "+fileName +"filenameview = "+holder.fileNameView); holder.fileNameView.setText(fileName); final int tempPosition = position; if(null != mOnItemClickListener) { holder.itemView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mOnItemClickListener.onClickItem(tempPosition,fileName); } }); // holder.itemView.setOnLongClickListener( new View.OnLongClickListener() { // @Override // public boolean onLongClick(View v) { // mOnItemClickListener.onLongClick(tempPosition,fileName); // return false; // } // }); } } //返回子项个数 @Override public int getItemCount() { return mFileList.size(); } public interface OnItemClickListener{ void onClickItem( int position,String fileName); // void onLongClickItem( int position,String fileName); } public void setOnItemClickListener(OnItemClickListener onItemClickListener ){ this.mOnItemClickListener = onItemClickListener; } }
当前名称:PopupWindow+RecyclerView实现上下滑动框功能-创新互联
标题来源:http://azwzsj.com/article/ddgejc.html