adapter

Framework7――封装

匿名 (未验证) 提交于 2019-12-02 23:49:02
强依赖:jQuery,Framework7 3,除非不支持jQuery,不然就是不支持Framework7,不然不可能不兼容 封装原则:在未来可能使用其他框架的前提下,在保证框架的可用性的同时,尽可能地提高复用性,尽量去除Framework7的个性化代码,一个组件一个对象,根据开发逐步添加函数相对的,如果使用Vue或者其它,最好不要一起操作同一个dom,因为封装基于jQuery的dom操作 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <!-- framework7 --> <link rel="stylesheet" href="framework7/dist/css/framework7.min.css"> <link rel="stylesheet" href="framework7/dist/css/framework7.md.min.css"> </head> <body> <div id="container" class='main-table' id="as-main-table" style="overflow: hidden"> </div> <br> <div id="container2" class="list links-list"> <

自定义RecyclerView实现下拉刷新,加载更多

匿名 (未验证) 提交于 2019-12-02 22:56:40
RecyclerView出来的时间已经不短了,现在估计大部分的列表类的需求实现首选肯定是RecyclerView,基本上可以跟ListView说再见了。那么问题来了,一般情况下一个列表页面都会有下拉刷新和加载更多功能,RecyclerView本身并没有下拉刷新和加载更多功能,当然现在已经有很多优秀的开源的支持下拉刷新,加载更多功能的三方RecyclerView,可以直接拿过来用。但是。。。有时候光会用是不够的,还需要知道它们是这么实现的,实现的原理是什么。下面就来介绍一下RecyclerView下拉刷新,加载更多功能的实现套路。 要达到上面的效果首先要考虑的是这个顶部下拉的刷新的view和底部加载更多的view放在什么地方合适,答案就是自定义一个WrapAdapter适配器,通过包装Adapter来提供header和footer。因为RecyclerView的Adapter是支持显示多种不同类型的view的,只需要重写RecyclerView.Adapter的 getItemViewType(int position)方法,根据不同位置返回不同类型即可。可以利用这个特性把第0个位置和最后一个位置预留出来,固定把第0个item存放下拉刷新的view,把最后一个位置存放加载更多的view。 具体代码如下: /** * 实现显示头部和尾部item的adapter

What is the difference between listeners and adapters?

让人想犯罪 __ 提交于 2019-12-02 22:15:10
I'm trying to differentiate between listeners and adapters. Are they pretty much the same but in listeners you have to implement all the methods in the interface, but with adapters you have an option to only implement the methods you need so the code is cleaners and easier to read? I also got told that adapters enable instantiation with only one implementation and you can't instantiate listeners, I don't fully understand this. Can someone please explain which one is better to use and things you can do with one but you can't with the other? WindowListener is interface which force you to

VirtualBox网络连接方式

匿名 (未验证) 提交于 2019-12-02 21:59:42
VirtualBox图形界面下有四种网络接入方式,它们分别是: 1、NAT 网络地址转换模式(NAT,Network Address Translation) 2、Bridged Adapter 桥接模式 3、Internal 内部网络模式 4、Host-only Adapter 主机模式 而在CommandLine下则有八种方式,除上面列出的四种外还有下列四种: 1.UDP Tunnel networking 2.VDE networking 3.Limiting bandwidth for network I/O 4.Improving network performance VirturalBox为每个虚拟机提供八种虚拟的PCI 网卡,对于每一种虚拟网卡,你可以从下列六种网络硬件中任选一种: AMD PCNet PCI II (Am79C970A) AMD PCNet FAST III (Am79C973, the default) Intel PRO/ 1000 MT Desktop ( 82540EM)(Windows Vista and later versions) Intel PRO/ 1000 T Server ( 82543GC)(Windows XP) Intel PRO/ 1000 MT Server ( 82545EM)(OVF imports from

can we call startActivityForResult from adapter?

不打扰是莪最后的温柔 提交于 2019-12-02 21:48:21
is it possible to have method onActivityResume within adapter & call startActivityForResult ? Yes. Just pass the context of the activity to the adapter in the adapter's constructor (here stored as mContext). In getView, just call ((Activity) mContext).startActivityForResult(intent,REQUEST_FOR_ACTIVITY_CODE); Not necessarily pass to pass context in adapter's constructor. You can get context from parent ViewGroup. Sample for RecyclerView adapter: Context mContext; @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { mContext = parent.getContext(); ... }

RecyclerVIew onItemClickListener Not working

别等时光非礼了梦想. 提交于 2019-12-02 20:51:05
问题 I am working on RecyclerView and try to using on click listener for each item of recyclcerview using Interface Here is my Activity class: public class LegacyHomeActivity extends ActivityBaseDrawer { private List<LegacyVideo> legacyVideoList = null; private List<Video> videoList = new ArrayList<>(); private RecyclerView mRecyclerView; private LegacyModeHomeAdapter adapter; @Override public void onNetworkStateChanged(boolean connected) { } @Override protected void onCreate(Bundle

适配器模式(Adapter Pattern)

匿名 (未验证) 提交于 2019-12-02 20:37:20
适配器模式(Adapter Pattern) 是作为两个不兼容的接口之间的桥梁。 例子:读卡器是作为内存卡和笔记本之间的是适配器,内存卡插入读卡器,读卡器再插入笔记本电脑。 参考资料: http://www.runoob.com/design-pattern/adapter-pattern.html Java设计模式之《适配器模式》及应用场景 - 唯一浩哥 - 博客园 作用:将一个类的接口转换成客户希望的另一个接口。适配器模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。 何时使用:1.要使用已有的一个类的方法,但是不符合我们的使用规范,且我们不知道其源码,无法copy。2。建立一个重复使用的类,用于联系一些彼此之间没有太大联系的类。3.通过接口的转换,将一个类插入到另一个类中。 如何实现 :继承或者依赖。适配器继承或者依赖已有的代码,实现目标类的接口。 注意事项 :适配器不是在详细设计时添加的,而是解决正在服役的项目的问题。 适配器有两种模式:这两种的差别在于一个是继承源角色类,一个是获取源角色类的对象。   类适配器模式:(继承源角色)   对象适配器模式:(获取源角色对象) 差别 :1.类适配器的话,因为是继承了源角色类的关系,所以不能去处理源角色类的子类。而对象适配器则没有关系,一个适配器可以将其源类和其子类都适配到目标接口。 代码实现:类适配器模式 1 /**

no change/black screen by notifyDataSetChanged();

放肆的年华 提交于 2019-12-02 18:22:36
问题 I want to do something like this. while pressing the refresh button, it will refresh the list. Activity codes are like this: adapter = new TweetAdapter(Welcome.this, tweets, users); tweetsList.setAdapter(adapter); private void refreshAdapter() { adapter.clear(); adapter.refresh(tweets, users); } refreshAdapter() called when I need to change the list item. here tweets & users are ArrayList & HashMap items and the adapter part is like this: public void clear() { this.tweets.clear(); this.users

How to ignore the first item in array adapter

大城市里の小女人 提交于 2019-12-02 17:59:42
问题 public class ListViewImgAdapter extends BaseAdapter { public static final String TAG = "ListViewImgAdapter"; private final int plastic_randomNum = 218947932; private final int plastic_iconNum = 98367590; int mGalleryItemBackground; private Context mContext; public int pageCount = Broker.model.issueFilter.issueShowingList().size(); public String[] mImageIds; public ListViewImgAdapter(Context c) { mContext = c; } public void updateListSize() { pageCount = Broker.model.issueFilter

How to refresh a view in main activity from an adapter?

喜夏-厌秋 提交于 2019-12-02 16:57:09
问题 I have a graph in main activity also I have a recycler view in main activity. Custom adapter is used for recyclerview. I have a check box and swipe layout in list item layout. in swipe layout there is a delete button. I want to reset the graph of main activity when I check the check box or when I delete any item. For this I created one method in main activity. And called this method in adapter onCheckedChangeListener and on click of delete. But I am getting a null pointer exception on