股票场内基金交易,没时间盯盘?
使用优财助手电脑客户端记录下您的股票买入卖出数据,能帮您时刻盯盘,会根据您记录的未售出买入价计算上涨或下跌幅度,及时弹框通知您。想知道如何使用?快点击左方视频观看了解吧~~下载地址:http://youcaizhushou.com
在项目中依赖使用
1 2 3 4 |
dependencies { compile 'com.github.cmc00022:easyrecycleradapters:1.1.1' } |
使用用法
创建一个自定义ViewHolder
继承EasyViewHolder
将EasyViewHolder类型控制为你所建的实体类
1 2 3 4 5 6 7 8 9 10 |
public class MyViewHolder extends EasyViewHolder<实体类> { public MyViewHolder(Context context, ViewGroup parent) { super(context, parent, R.layout.子视图); } @Override public void bindTo(int position, 实体类 value) { //这里负责处理子视图内的控件处理 //position即是每个子视图的位置。 } } |
配合EasyRecyclerAdapter使用
1 2 |
recyclerAdapter=new EasyRecyclerAdapter(this,Student.class,MyViewHolder.class); |
第二个参数分别是实体类,和你创建的ViewHolder类。
1 2 3 |
recyclerAdapter.addAll(mStudentList);//加入数据 recyclerView.setLayoutManager(new LinearLayoutManager(this)); |
设定一个布局管理器,看LinearLayoutManager这个命名,在XML中你应该知道这个控制布局的方式LinearLayout
当然你还可以试一试new GridLayoutManager(this,count),这第二个参数用于你想在展示多少列的子视图
1 2 |
recyclerView.setAdapter(recyclerAdapter);//设定适配器 |
这十几行代码就搞定了RecyclerView的构建,你只需要专心于子视图内控件的处理
EasyRecyclerAdapter的实战
创建一个Student实体类
1 2 3 4 5 6 7 8 9 10 |
public class Student { public int id; public String name; public Student(int id, String name) { this.id = id; this.name = name; } } |
准备RecyclerView的一个子视图(item.xml)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="@color/textWhite" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/txt_Studentname" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/txt_Studentid" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> |
创建一个自定义的适配器
定义为MyViewHolder,让他继承自EasyViewHolder,然后我们看到这里标红了,这里需要创建一个构造器和复写EasyViewHolder的bindto()的方法。
现在我们结合一下ButterKnifer方便的绑定控件的方式,配合使用EasyViewHolder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
public class MyViewHolder extends EasyViewHolder<Student> { @BindView(R.id.txt_Studentid)TextView mTxtStudentName; @BindView(R.id.txt_Studentname)TextView mTxtStudentId; //如果你是选择自动构建构造器的话,即ctrl+Enter,会创建出以下内容,这个是会出问题的。 //public MyViewHolder(Context context, ViewGroup parent,int layyoutId) { //super(context, parent, R.layout.item);//这里传入一个子视图. //ButterKnife.bind(this,itemView); //} public MyViewHolder(Context context, ViewGroup parent) { super(context, parent, R.layout.item);//这里传入一个子视图. ButterKnife.bind(this,itemView); } @Override public void bindTo(int position, Student student) { mTxtStudentId.setText(student.id+""); mTxtStudentName.setText(student.name); mTxtStudentName.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //这个bindTo还可以添加监听,仔细研究一下这个position,就是每个子视图在父视图的位置 Toast.makeText(mContext,"position="+position,Toast.LENGTH_SHORT).show(); } }); } } |
准备好一个父视图(students.xml)
1 2 3 4 5 6 7 8 9 10 11 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerview" android:layout_width="match_parent" android:layout_height="wrap_content"> </android.support.v7.widget.RecyclerView> </LinearLayout> |
在Activity中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
public class ExamArticleActivity extends BaseActivity { private EasyRecyclerAdapter recyclerAdapter; private List<Student> mStudentList=new ArrayList<Student>(); @BindView(R.id.recyclerview) RecyclerView recyclerView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.students); ButterKnife.bind(this); initRecycleView();//初始化RecyclerView } private void initRecycleView() { recyclerAdapter=new EasyRecyclerAdapter(this,Student.class,MyViewHolder.class); initdata();//初始化数据 recyclerAdapter.addAll(mStudentList);//加入数据进EasyRecyclerViewAdapter recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setAdapter(recyclerAdapter); recyclerView.addItemDecoration(new SpaceItemDecoration(getResources().getDimensionPixelSize(R.dimen.padding_10dp))); }//设置间隔 public class SpaceItemDecoration extends RecyclerView.ItemDecoration { //增加RecyclerView子项目之间的间隔 private int space; public SpaceItemDecoration(int space) { this.space = space; } @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.getChildLayoutPosition(view) != 0) outRect.top = space; } } private void initdata() {//准备一些数据 Student student1=new Student(1,"小明"); Student student2=new Student(2,"小红"); Student student3=new Student(3,"小刚"); mStudentList.add(student1); mStudentList.add(student2); mStudentList.add(student3); } } |
EasyRecyclerAdapter的Github资源
EasyViewHolder比较好用,但建议还是先把最基础RecyclerView的用法先实现一遍,这个开源库只是帮我们减少重复的代码。还有特殊的情况这个是使用不了的,Fragment嵌套Fragment的时候。
Github主页 https://github.com/CarlosMChica/easyrecycleradapters
想获得去掉 5 元限制的证券账户吗?

证券交易股票基金的佣金,不足 5 元会按照 5 元收取。比如交易 1000 元的股票,按照普遍的证券佣金手续费率万 2.5,其交易佣金为 0.25 元,小于 5 元,实际会收取佣金 5 元,买卖两次需要支付 10 元佣金成本,1% 的利润就这样没了。
如果您想去掉最低交易佣金 5 元限制,使用微信扫描左边小程序二维码,访问微信小程序「优财助手」,点击底部菜单「福利」,阅读文章「通过优财开证券账户无最低交易佣金 5 元限制」,按照文章步骤操作即可获得免 5 元证券账户,股票基金交易手续费率万 2.5。
请注意,一定要按照文章描述严格操作,如错误开户是无法获得免 5 元证券账户的。
如果您想去掉最低交易佣金 5 元限制,使用微信扫描左边小程序二维码,访问微信小程序「优财助手」,点击底部菜单「福利」,阅读文章「通过优财开证券账户无最低交易佣金 5 元限制」,按照文章步骤操作即可获得免 5 元证券账户,股票基金交易手续费率万 2.5。
请注意,一定要按照文章描述严格操作,如错误开户是无法获得免 5 元证券账户的。