google在Android support v7包中提供了SearchView,开放的方法很少,导致SearchView自定义比较麻烦。但是SearchView往往是业务中常用的控件,其实实现也很简单,可以自己动手打造一个易扩展,可自定义的SearchView,来满足以后项目中的需求,下面就记录一下封装SearchView的详细过程。
//search to do 搜索逻辑 protectedabstractvoiddoSearch(); //set result list adapter 设置结果列表适配器 protectedabstract RecyclerView.Adapter setResultListAdapter();
//set result list divider 设置结果列表分割线,可重写 protected RecyclerView.ItemDecoration setResultListDivider(){ returnnew RecycleViewDivider(this, LinearLayoutManager.HORIZONTAL, 10, getResources().getColor(R.color.bg)); }
//set result list LayoutManager 设置RecyclerView的布局管理器 protected RecyclerView.LayoutManager setLayoutManager(){ returnnew LinearLayoutManager(this); }
//init result fragment 初始化结果分页 protectedvoidinitResultFragment(int SearchFragmentId){ resultFragment = new ResultFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// Bundle bundle = new Bundle(); // fragment.setArguments(bundle);
Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter] 这个时候直接回车就好,你也可以输入特定的文件名,如/c/Users/you/.ssh/id_rsa来保存
Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again] 这个时候不写密码也可以 密钥创建成功后,输入