1. 程式人生 > >Android CheckBox實現狀態選擇動畫

Android CheckBox實現狀態選擇動畫

話不多說,只是為了幫助節約時間...


1.ResumeSearchResultActivity類

package com.risfond.rnss.home.resume.activity;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

import com.risfond.rnss.R;
import com.risfond.rnss.base.BaseActivity;
import com.risfond.rnss.callback.ResponseCallBack;
import com.risfond.rnss.common.constant.URLConstant;
import com.risfond.rnss.common.utils.CustomDialog;
import com.risfond.rnss.common.utils.DialogUtil;
import com.risfond.rnss.common.utils.ImeUtil;
import com.risfond.rnss.common.utils.JsonUtil;
import com.risfond.rnss.common.utils.NumberUtil;
import com.risfond.rnss.common.utils.SPUtil;
import com.risfond.rnss.common.utils.ToastUtil;
import com.risfond.rnss.common.utils.net.NetUtil;
import com.risfond.rnss.entry.ResumeSearch;
import com.risfond.rnss.entry.ResumeSearchAll;
import com.risfond.rnss.entry.ResumeSearchResponse;
import com.risfond.rnss.home.commonFuctions.myAttenDance.activity.MyAttendanceActivity;
import com.risfond.rnss.home.resume.adapter.ResumeSearchAdapter;
import com.risfond.rnss.home.resume.adapter.ResumeSearchHistoryAdapter;
import com.risfond.rnss.home.resume.adapter.ResumeSearchWholeAdapter;
import com.risfond.rnss.home.resume.fragment.EducationFragment;
import com.risfond.rnss.home.resume.fragment.ExperienceFragment;
import com.risfond.rnss.home.resume.fragment.MoreFragment;
import com.risfond.rnss.home.resume.fragment.PositionFragment;
import com.risfond.rnss.home.resume.modleImpl.ResumeSearchAllImpl;
import com.risfond.rnss.home.resume.modleImpl.ResumeSearchImpl;
import com.risfond.rnss.home.resume.modleInterface.IResumeSearch;
import com.risfond.rnss.home.resume.modleInterface.SelectCallBack;
import com.risfond.rnss.widget.RecycleViewDivider;


import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnCheckedChanged;
import butterknife.OnClick;

/**
 * 簡歷搜尋結果頁面
 */
public class ResumeSearchResultActivity extends BaseActivity implements ResponseCallBack, SelectCallBack {

    @BindView(R.id.et_resume_search)
    EditText etResumeSearch;
    @BindView(R.id.rv_resume_search_history)
    RecyclerView rvResumeSearchHistory;
    @BindView(R.id.ll_empty_history)
    LinearLayout llEmptyHistory;
    @BindView(R.id.ll_history)
    LinearLayout llHistory;
    @BindView(R.id.tv_resume_total)
    TextView tvResumeTotal;
    @BindView(R.id.tv_search_cancel)
    TextView tvSearchCancel;
    @BindView(R.id.rv_resume_list)
    RecyclerView rvResumeList;
    @BindView(R.id.ll_empty_search)
    LinearLayout llEmptySearch;
    @BindView(R.id.ll_resume)
    LinearLayout llResume;
    @BindView(R.id.activity_resume_search_result)
    LinearLayout activityResumeSearchResult;
    @BindView(R.id.cb_position)
    CheckBox cbPosition;
    @BindView(R.id.cb_experience)
    CheckBox cbExperience;
    @BindView(R.id.cb_education)
    CheckBox cbEducation;
    @BindView(R.id.cb_more)
    CheckBox cbMore;
    @BindView(R.id.line)
    View line;
    @BindView(R.id.frame)
    View Frame;
    @BindView(R.id.tv_search_save)
    TextView tvSave;//儲存搜尋簡歷
    @BindView(R.id.cb_whole)
    CheckBox cbWhole;//搜尋分類按鈕

    private Context context;
    private ResumeSearchAdapter adapter;
    private ResumeSearchHistoryAdapter historyAdapter;
    private Map<String, String> request;
    private IResumeSearch iResumeSearch;
    private int pageindex = 1;
    private ResumeSearchResponse response;
    private List<ResumeSearch> searches = new ArrayList<>();
    private List<ResumeSearch> temp = new ArrayList<>();

    private List<ResumeSearchAll> searcheall = new ArrayList<>();
    private boolean isLoadMore;
    private boolean isCanLoadMore = true;
    private boolean isLoadingMore = false;
    private List<String> histories;
    private List<String> historiesAESC;

    private FragmentTransaction transaction;
    private ExperienceFragment experienceFragment;
    private PositionFragment positionFragment;
    private EducationFragment educationFragment;
    private MoreFragment moreFragment;

    private List<String> selectedIds = new ArrayList<>();//城市ID
    private List<String> selectedNames = new ArrayList<>();//城市名稱
    private List<String> educations = new ArrayList<>();//學歷ID
    private List<String> educationNames = new ArrayList<>();//學歷名稱
    private String experience_from = "";//經驗from
    private String experience_to = "";//經驗to
    private List<String> languages = new ArrayList<>();//語言ID
    private List<String> languages_text = new ArrayList<>();//語言ID
    private List<String> recommends = new ArrayList<>();//推薦狀態ID
    private List<String> sexs = new ArrayList<>();//性別ID
    private List<String> sexs_texts = new ArrayList<>();//建立一個集合
    private String age_From = "";//年齡from
    private String age_To = "";//年齡to
    private String salary_From = "";//薪資from
    private String salary_To = "";//薪資to

    private String yearfrom = "";
    private String yearto = "";
    private String edufrom = "";
    private String eduto = "";
    private String agefrom = "";
    private String ageto = "";
    private String salaryfrom = "";
    private String salaryto = "";
    private boolean isHasData;

    private PopupWindow popupwindow;
    private ResumeSearchWholeAdapter resumeSearchWholeAdapter;
    private ResumeSearchAllImpl resumeSearchAll;


    @Override
    public int getContentViewResId() {
        return R.layout.activity_resume_search_result;
    }

    @Override
    public void init(Bundle savedInstanceState) {
        context = ResumeSearchResultActivity.this;
        histories = new ArrayList<>();
        historiesAESC = new ArrayList<>();
        iResumeSearch = new ResumeSearchImpl();

        resumeSearchAll = new ResumeSearchAllImpl();//搜尋全部

        cbWhole.setText("全部");//初始值
        rvResumeList.setLayoutManager(new LinearLayoutManager(context));
        rvResumeList.addItemDecoration(new RecycleViewDivider(context, LinearLayoutManager.HORIZONTAL, 20, ContextCompat.getColor(context, R.color.color_home_back)));

        rvResumeSearchHistory.setLayoutManager(new LinearLayoutManager(context));
        rvResumeSearchHistory.addItemDecoration(new RecycleViewDivider(context, LinearLayoutManager.HORIZONTAL, 2, ContextCompat.getColor(context, R.color.color_home_back)));

        adapter = new ResumeSearchAdapter(context, searches);
        historyAdapter = new ResumeSearchHistoryAdapter(context, historiesAESC);
        resumeSearchWholeAdapter = new ResumeSearchWholeAdapter(context, searcheall);


        rvResumeList.setAdapter(adapter);

        checkSearchEditText();
        etResumeSearch.setFocusable(false);
        initHistoryData();
        itemClick();
        scroll();

    }

    /**
     * 請求簡歷列表
     *
     * @param contact
     */
    private void resumeRequest(String contact) {
        if (!isLoadMore) {
            DialogUtil.getInstance().showLoadingDialog(context, "搜尋中...");
        }
        request = new HashMap<>();

        request.put("keyword", contact);
        request.put("staffid", String.valueOf(SPUtil.loadId(context)));
        request.put("pageindex", String.valueOf(pageindex));

        for (int i = 0; i < selectedIds.size(); i++) {
            String key = "worklocation[" + i + "]";
            request.put(key, selectedIds.get(i));
        }

        request.put("yearfrom", yearfrom);
        request.put("yearto", yearto);

        for (int i = 0; i < educations.size(); i++) {
            String key = "edu[" + i + "]";
            request.put(key, educations.get(i));
        }

        request.put("agefrom", agefrom);
        request.put("ageto", ageto);

        if (sexs.size() > 0) {
            request.put("gender[0]", sexs.get(0));
        }

        request.put("salaryfrom", salaryfrom);
        request.put("salaryto", salaryto);

        if (recommends.size() > 0) {
            request.put("resumestatus[0]", recommends.get(0));
        }

        for (int i = 0; i < languages.size(); i++) {
            String key = "lang[" + i + "]";
            request.put(key, languages.get(i));
        }

        iResumeSearch.resumeRequest(SPUtil.loadToken(context), request, URLConstant.URL_RESUME_SEARCH, this);
    }

    @OnClick({R.id.tv_search_cancel,R.id.tv_search_save})//監聽事件
    public void onClick(View v) {
        if (v.getId() == R.id.tv_search_cancel) {
            ImeUtil.hideSoftKeyboard(etResumeSearch);
            onFinish();
        }
        if (v.getId() == R.id.tv_search_save) {

            //彈框對話
            CustomDialog.Builder builder = new CustomDialog.Builder(context);
            builder.setMessage("您已儲存成功,可在快捷搜尋檢視");
            builder.setPositiveButton("確認", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    //設定你的操作事項

                    if (isCanLoadMore) {

                            if (!isLoadingMore) {
                                isLoadMore = true;
                                isLoadingMore = true;
                                resumeRequests();
                            }
                    }
                }
            });

            builder.create().show();//顯示
        }
    }

    private void resumeRequests() {
        request = new HashMap<>();
        request.put("keyword", "");
        request.put("staffid", String.valueOf(SPUtil.loadId(context)));
        request.put("pageindex", String.valueOf(pageindex));
        for (int i = 0; i < selectedIds.size(); i++) {
            String key = "worklocation[" + i + "]";
            request.put(key, selectedIds.get(i));
        }

        request.put("yearfrom", yearfrom);
        request.put("yearto", yearto);

        for (int i = 0; i < educations.size(); i++) {
            String key = "edu[" + i + "]";
            request.put(key, educations.get(i));
        }

        request.put("agefrom", agefrom);
        request.put("ageto", ageto);

        if (sexs.size() > 0) {
            request.put("gender[0]", sexs.get(0));
        }

        request.put("salaryfrom", salaryfrom);
        request.put("salaryto", salaryto);

        if (recommends.size() > 0) {
            request.put("resumestatus[0]", recommends.get(0));
        }

        for (int i = 0; i < languages.size(); i++) {
            String key = "lang[" + i + "]";
            request.put(key, languages.get(i));
        }

        iResumeSearch.resumeRequest(SPUtil.loadToken(context), request, URLConstant.URL_RESUME_ADDRESUMEQUERY, this);
//        callBack.onMoreConfirm(recommends, age_From, age_To, sexs,sexs_texts, salary_From, salary_To, languages,languages_text, page);//回撥
//        Log.i("TAG",request.toString()+"=============================");
    }

    private void checkSearchEditText() {
        etResumeSearch.setOnTouchListener(new View.OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {
                etResumeSearch.setFocusableInTouchMode(true);
                etResumeSearch.setFocusable(true);
                etResumeSearch.requestFocus();
                initHistoryData();
                clearAllSelected();
                return false;
            }
        });

        etResumeSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH) {//點選“搜尋”軟鍵盤
                    ImeUtil.hideSoftKeyboard(etResumeSearch);
                    pageindex = 1;
                    searches.clear();
                    resumeRequest(etResumeSearch.getText().toString().trim());
                    saveHistory(etResumeSearch.getText().toString().trim());
                }
                return false;
            }
        });

    }

    private void initResumeData() {
        if (llHistory != null) {
            llHistory.setVisibility(View.GONE);
        }
        if (llResume != null) {
            llResume.setVisibility(View.VISIBLE);
        }
        adapter.updateData(searches);
        hideResume();
    }

    /**
     * 獲取並顯示搜尋歷史
     */
    private void initHistoryData() {
        llHistory.setVisibility(View.VISIBLE);
        llResume.setVisibility(View.GONE);
        historiesAESC.clear();
        histories = SPUtil.loadSearchHistoryArray(context);
        for (int i = histories.size() - 1; i >= 0; i--) {
            historiesAESC.add(histories.get(i));
        }
        rvResumeSearchHistory.setAdapter(historyAdapter);
        historyAdapter.updateHistory(historiesAESC);
        hideHistory();
    }

    private void itemClick() {
        //搜尋裡的列表點選
        historyAdapter.setOnItemClickListener(new ResumeSearchHistoryAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                //如果點選的是清除歷史記錄
                if (historyAdapter.isFooterView(position)) {
                    ImeUtil.hideSoftKeyboard(etResumeSearch);
                    histories.clear();
                    historiesAESC.clear();
                    historyAdapter.updateHistory(historiesAESC);
                    SPUtil.saveSearchHistoryArray(context, histories);
                    hideHistory();
                } else {
                    if (NetUtil.isConnected(context)) {
                        pageindex = 1;
                        searches.clear();
                        ImeUtil.hideSoftKeyboard(etResumeSearch);
                        resumeRequest(historiesAESC.get(position));
                        etResumeSearch.setText(historiesAESC.get(position));
                        saveHistory(historiesAESC.get(position));
                    } else {
                        ToastUtil.showImgMessage(context, "請檢查網路連線");
                    }

                }
            }
        });

        historyAdapter.setOnDeleteClickListener(new ResumeSearchHistoryAdapter.OnDeleteClickListener() {
            @Override
            public void onDeleteClick(View view, int position) {
                histories.remove(historiesAESC.get(position));
                SPUtil.saveSearchHistoryArray(context, histories);
                historiesAESC.remove(position);
                historyAdapter.updateHistory(historiesAESC);
            }
        });

        //簡歷列表點選
        adapter.setOnItemClickListener(new ResumeSearchAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                ResumeDetailActivity.startAction(context, String.valueOf(searches.get(position).getId()));
            }
        });
    }

    private void scroll() {
        rvResumeList.addOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
                int last = manager.findLastCompletelyVisibleItemPosition();
                int totalCount = manager.getItemCount();
                // last >= totalCount - x表示剩餘x個item是自動載入,可自己設定
                // dy>0表示向下滑動
                if (isCanLoadMore) {
                    if (last >= totalCount - 5 && dy > 0) {
                        if (!isLoadingMore) {
                            isLoadMore = true;
                            isLoadingMore = true;
                            resumeRequest(etResumeSearch.getText().toString().trim());
                        }
                    }
                }
            }
        });
    }

    private void updateHistory(String text) {
        for (int i = 0; i < histories.size(); i++) {
            if (histories.get(i).equals(text)) {
                histories.remove(i);
                break;
            }
        }
        if (histories.size() == 15) {
            histories.remove(0);
        }
        histories.add(text);
        SPUtil.saveSearchHistoryArray(context, histories);
    }

    /**
     * 搜素記錄只儲存15條
     */
    private void saveHistory(String text) {
        updateHistory(text);
    }

    private void hideHistory() {
        if (historiesAESC.size() > 0) {
            rvResumeSearchHistory.setVisibility(View.VISIBLE);
            llEmptyHistory.setVisibility(View.GONE);
        } else {
            rvResumeSearchHistory.setVisibility(View.GONE);
            llEmptyHistory.setVisibility(View.VISIBLE);
        }
    }

    private void hideResume() {
        if (searches.size() > 0) {
            if (rvResumeList != null) {
                rvResumeList.setVisibility(View.VISIBLE);
            }
            if (llEmptySearch != null) {
                llEmptySearch.setVisibility(View.GONE);
            }
        } else {
            if (rvResumeList != null) {
                rvResumeList.setVisibility(View.GONE);
            }
            if (llEmptySearch != null) {
                llEmptySearch.setVisibility(View.VISIBLE);
            }
        }
    }

    public static void StartAction(Context context) {
        Intent intent = new Intent(context, ResumeSearchResultActivity.class);
        context.startActivity(intent);
    }


    @Override
    public void onSuccess(final Object obj) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (!isLoadMore) {
                    DialogUtil.getInstance().closeLoadingDialog();
                }
                if (obj instanceof ResumeSearchResponse) {
                    response = (ResumeSearchResponse) obj;
                    if (tvResumeTotal != null) {
                        tvResumeTotal.setText(NumberUtil.formatString(new BigDecimal(response.getTotal())));
                    }
                    if (response.getData().size() == 15) {
                        pageindex++;
                        isCanLoadMore = true;
                        if (temp.size() > 0) {
                            searches.removeAll(temp);
                            temp.clear();
                        }
                        searches.addAll(response.getData());
                    } else {
                        isCanLoadMore = false;
                        if (temp.size() > 0) {
                            searches.removeAll(temp);
                            temp.clear();
                        }
                        temp = response.getData();
                        searches.addAll(temp);
                    }
                    initResumeData();
                    adapter.updateData(searches);
                }
                if (isLoadMore) {
                    isLoadingMore = false;
                }
                isLoadMore = false;
            }
        });
    }

    @Override
    public void onFailed(String str) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (!isLoadMore) {
                    DialogUtil.getInstance().closeLoadingDialog();
                    initResumeData();
                    ToastUtil.showShort(context, "搜尋失敗");
                }
            }
        });
    }

    @Override
    public void onError(String str) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (!isLoadMore) {
                    DialogUtil.getInstance().closeLoadingDialog();
                    initResumeData();
                }
            }
        });
    }

    @OnCheckedChanged({R.id.cb_position, R.id.cb_experience, R.id.cb_education, R.id.cb_more,R.id.cb_whole})
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        ImeUtil.hideSoftKeyboard(etResumeSearch);

        switch (buttonView.getId()) {
            case R.id.cb_position:
                if (isChecked) {
                    checkedPosition();
                    initPositionFragment();
                } else {
                    Frame.setVisibility(View.GONE);
                    clearPositionFragment();
                }
                break;
            case R.id.cb_experience:
                if (isChecked) {
                    checkedExperience();
                    initExperienceFragment();
                } else {
                    Frame.setVisibility(View.GONE);
                    clearExperienceFragment();
                }
                break;
            case R.id.cb_education:
                if (isChecked) {
                    checkedEducation();
                    initEducationFragment();
                } else {
                    Frame.setVisibility(View.GONE);
                    clearEducationFragment();
                }
                break;
            case R.id.cb_more:
                if (isChecked) {
                    checkedMore();
                    initMoreFragment();
                } else {
                    Frame.setVisibility(View.GONE);
                    clearMoreFragment();
                }
                break;
            case R.id.cb_whole://搜尋分類
                if (isChecked) {

                    if (popupwindow != null && popupwindow.isShowing()) {
                        popupwindow.dismiss();
                        cbWhole.setChecked(false);
                        return;
                    } else {
                        initmPopupWindowView();
                        popupwindow.showAsDropDown(buttonView, 0, 5);
                    }
                }else if(!isChecked){
                    cbWhole.setChecked(false);
                }
                break;
        }
    }

    /**
     * popupwindow分類方法
     */
    public void initmPopupWindowView() {

        // // 獲取自定義佈局檔案pop.xml的檢視
        View customView = LayoutInflater.from(ResumeSearchResultActivity.this).inflate(R.layout.popview_item_whole, null);
        // 建立PopupWindow例項,200,150分別是寬度和高度
        popupwindow = new PopupWindow(customView,
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
        // 設定動畫效果 [R.style.AnimationFade 是自己事先定義好的]
        //        popupwindow.setAnimationStyle(R.style.AnimationFade);
        // 自定義view新增觸控事件
        //        popupwindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
        popupwindow.setFocusable(false);
        popupwindow.setOutsideTouchable(false); // 設定是否允許在外點選使其消失,到底有用沒?

        //        popupwindow.getContentView().measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        //        int popupWidth = popupwindow.getContentView().getMeasuredWidth();
        //        int popupHeight = popupwindow.getContentView().getMeasuredHeight();
        //        // 設定好引數之後再show
        //        int[] location = new int[2];
        //        customView.getLocationOnScreen(location);
        //        popupwindow.showAtLocation(customView,  Gravity.CENTER_HORIZONTAL, (location[0]+customView.getWidth()/2)-popupWidth/2 , location[1]-popupHeight);


        customView.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (popupwindow != null && popupwindow.isShowing()) {
                    popupwindow.dismiss();
                    popupwindow = null;
                    cbWhole.setChecked(false);
                }

                return false;
            }
        });

        /** 在這裡可以實現自定義檢視的功能 */
        final TextView whole = (TextView) customView.findViewById(R.id.tv_one);//全部
        final TextView positions = (TextView) customView.findViewById(R.id.tv_two);//職位
        final TextView company = (TextView) customView.findViewById(R.id.tv_three);//公司
        //監聽事件
        whole.setOnClickListener(new View.OnClickListener() {
                                      @Override
                                      public void onClick(View view) {
                                          cbWhole.setText("全部");
                                              if (popupwindow != null && popupwindow.isShowing()) {
                                                  popupwindow.dismiss();
                                                  popupwindow = null;
                                                  cbWhole.setChecked(false);
                                                  rvResumeList.setAdapter(resumeSearchWholeAdapter);
                                                  request = new HashMap<>();
                                                  request.put("keyword", "");
                                                  request.put("staffid", String.valueOf(SPUtil.loadId(context)));
                                                  request.put("pageindex", String.valueOf(pageindex));
                                                  request.put("selecttype", String.valueOf(0));
                                                  resumeSearchAll.resumeRequest(SPUtil.loadToken(context), request, URLConstant.URL_RESUME_SEARCHALL, ResumeSearchResultActivity.this);

                                          }
                                      }
                                  }

        );
        positions.setOnClickListener(new View.OnClickListener() {
                                      @Override
                                      public void onClick(View view) {
                                          cbWhole.setText("職位");
                                              if (popupwindow != null && popupwindow.isShowing()) {
                                                  popupwindow.dismiss();
                                                  popupwindow = null;
                                                  cbWhole.setChecked(false);//設定為預設狀態
                                          }
                                      }
                                  }

        );
        company.setOnClickListener(new View.OnClickListener() {
                                      @Override
                                      public void onClick(View view) {
                                          cbWhole.setText("公司");
                                              if (popupwindow != null && popupwindow.isShowing()) {
                                                  popupwindow.dismiss();
                                                  popupwindow = null;
                                                  cbWhole.setChecked(false);
                                          }
                                      }
                                  }

        );

    }

    //填充職位頁面
    private void initPositionFragment() {
        transaction = getSupportFragmentManager().beginTransaction();
        positionFragment = new PositionFragment(selectedIds, selectedNames, this);
        transaction.add(R.id.frame, positionFragment);
        transaction.commit();

        Frame.setVisibility(View.VISIBLE);

    }

    private void clearPositionFragment() {
        if (positionFragment != null) {
            transaction = getSupportFragmentManager().beginTransaction();
            transaction.remove(positionFragment);
            transaction.commit();
        }
    }

    //填充經驗頁面
    private void initExperienceFragment() {
        transaction = getSupportFragmentManager().beginTransaction();
        experienceFragment = new ExperienceFragment(experience_from, experience_to, this);
        transaction.add(R.id.frame, experienceFragment);
        transaction.commit();

        Frame.setVisibility(View.VISIBLE);

    }

    private void clearExperienceFragment() {
        if (experienceFragment != null) {
            transaction = getSupportFragmentManager().beginTransaction();
            transaction.remove(experienceFragment);
            transaction.commit();
        }
    }

    //填充學歷頁面
    private void initEducationFragment() {
        transaction = getSupportFragmentManager().beginTransaction();
        educationFragment = new EducationFragment(educations, educationNames, this);
        transaction.add(R.id.frame, educationFragment);
        transaction.commit();

        Frame.setVisibility(View.VISIBLE);
    }

    private void clearEducationFragment() {
        if (educationFragment != null) {
            transaction = getSupportFragmentManager().beginTransaction();
            transaction.remove(educationFragment);
            transaction.commit();
        }
    }

    //填充更多頁面
    private void initMoreFragment() {
        transaction = getSupportFragmentManager().beginTransaction();
        if (searches.size() > 0) {
            isHasData = true;
        } else {
            isHasData = false;
        }
        moreFragment = new MoreFragment(recommends, age_From, age_To, sexs,sexs_texts, salary_From,
                salary_To, languages,languages_text, String.valueOf(pageindex), isHasData, this);
        transaction.add(R.id.frame, moreFragment);
        transaction.commit();

        Frame.setVisibility(View.VISIBLE);
    }

    private void clearMoreFragment() {
        if (moreFragment != null) {
            transaction = getSupportFragmentManager().beginTransaction();
            transaction.remove(moreFragment);
            transaction.commit();
        }
    }

    private void ClearAllFragment() {
        clearPositionFragment();
        clearExperienceFragment();
        clearEducationFragment();
        clearMoreFragment();
    }

    private void checkedPosition() {
        cbExperience.setChecked(false);
        cbEducation.setChecked(false);
        cbMore.setChecked(false);
    }

    private void checkedExperience() {
        cbPosition.setChecked(false);
        cbEducation.setChecked(false);
        cbMore.setChecked(false);
    }

    private void checkedEducation() {
        cbPosition.setChecked(false);
        cbExperience.setChecked(false);
        cbMore.setChecked(false);
    }

    private void checkedMore() {
        cbPosition.setChecked(false);
        cbExperience.setChecked(false);
        cbEducation.setChecked(false);
    }

    private void clearAll() {
        cbPosition.setChecked(false);
        cbExperience.setChecked(false);
        cbEducation.setChecked(false);
        cbMore.setChecked(false);
    }

    private void onFinish() {
        if (Frame.getVisibility() == View.VISIBLE) {
            Frame.setVisibility(View.GONE);
            clearAll();
            ClearAllFragment();
        } else {
            finish();
        }
    }

    private void clearAllSelected() {
        Frame.setVisibility(View.GONE);
        clearAll();
        ClearAllFragment();

        experience_from = "";
        experience_to = "";
        age_From = "";
        age_To = "";
        salary_From = "";
        salary_To = "";
        yearfrom = "";
        yearto = "";
        edufrom = "";
        eduto = "";
        agefrom = "";
        ageto = "";
        salaryfrom = "";
        salaryto = "";

        languages.clear();
        recommends.clear();
        selectedIds.clear();
        selectedNames.clear();
        educations.clear();
        educationNames.clear();
        languages.clear();
        recommends.clear();
        sexs.clear();

        setPositionValue();
        setExperienceValue();
        setCbEducationValue();
        setMoreValue();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            onFinish();
        }
        return false;
    }

    private void setPositionValue() {
        String value = "";
        for (String str : selectedNames) {
            value += str + "+";
        }
        if (TextUtils.isEmpty(value)) {
            cbPosition.setText("地點");
        } else {
            cbPosition.setText(value.substring(0, value.length() - 1));
        }

    }

    private void setExperienceValue() {
        /*if (TextUtils.isEmpty(experience_from)) {
            yearfrom = "0";
        } else {
            yearfrom = experience_from;
        }
        if (TextUtils.isEmpty(experience_to)) {
            yearto = "0";
        } else {
            yearto = experience_to;
        }*/
        yearfrom = experience_from;
        yearto = experience_to;
        if (yearfrom.equals("") && yearto.equals("")) {
            cbExperience.setText("經驗");
        } else if (yearfrom.equals("") && !yearto.equals("")) {
            cbExperience.setText("不限-" + yearto);
        } else if (!yearfrom.equals("") && yearto.equals("")) {
            cbExperience.setText(yearfrom + "-不限");
        } else {
            cbExperience.setText(yearfrom + "-" + yearto);
        }

    }

    private void setCbEducationValue() {
        String value = "";
        for (String str : educationNames) {
            value += str + "+";
        }
        if (TextUtils.isEmpty(value)) {
            cbEducation.setText("學歷");
        } else {
            cbEducation.setText(value.substring(0, value.length() - 1));
        }

    }

    private void setMoreValue() {
        //年齡
        /*if (TextUtils.isEmpty(age_From)) {
            agefrom = "0";
        } else {
            agefrom = age_From;
        }
        if (TextUtils.isEmpty(age_To)) {
            ageto = "0";
        } else {
            ageto = age_To;
        }*/
        agefrom = age_From;
        ageto = age_To;
        //年薪
        /*if (TextUtils.isEmpty(salary_From)) {
            salaryfrom = "0";
        } else {
            salaryfrom = salary_From;
        }
        if (TextUtils.isEmpty(salary_To)) {
            salaryto = "0";
        } else {
            salaryto = salary_To;
        }*/
        salaryfrom = salary_From;
        salaryto = salary_To;
    }

    @Override
    public void onPositionConfirm(List<String> positions, List<String> names) {
        selectedIds = positions;
        selectedNames = names;
        setPositionValue();
        onFinish();
        searches.clear();
        pageindex = 1;
        resumeRequest(etResumeSearch.getText().toString().trim());
    }

    @Override
    public void onExperienceConfirm(String from, String to) {
        experience_from = from;
        experience_to = to;
        setExperienceValue();
        onFinish();
        searches.clear();
        pageindex = 1;
        resumeRequest(etResumeSearch.getText().toString().trim());
    }

    @Override
    public void onEducationConfirm(List<String> education, List<String> educationName) {
        educations = education;
        educationNames = educationName;
        setCbEducationValue();
        onFinish();
        searches.clear();
        pageindex = 1;
        resumeRequest(etResumeSearch.getText().toString().trim());
    }

    @Override
    public void onMoreConfirm(List<String> recommend, String from1, String to1, List<String> sex,List<String> sexs_text,
                              String from2, String to2, List<String> language,List<String> languages_text, String page) {
        recommends = recommend;
        age_From = from1;
        age_To = to1;
        sexs = sex;
        salary_From = from2;
        salary_To = to2;
        languages = language;

        setMoreValue();
        onFinish();
        searches.clear();
        pageindex = Integer.parseInt(page);
        resumeRequest(etResumeSearch.getText().toString().trim());
    }

    @Override
    public void onOutside() {
        onFinish();
    }

}

2.activity_resume_search_result佈局檔案

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_resume_search_result"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.risfond.rnss.home.resume.activity.ResumeSearchActivity">

    <include layout="@layout/include_resume_search_result_title"/>


    <LinearLayout
        android:id="@+id/ll_history"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:visibility="gone">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:background="@color/color_home_back"
            android:gravity="center_vertical"
            android:paddingLeft="15dp"
            android:text="搜尋歷史"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/rv_resume_search_history"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

        <LinearLayout
            android:id="@+id/ll_empty_history"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:gravity="center"
                android:text="暫無搜尋歷史"
                android:textColor="@color/color_home_gray_text"
                android:textSize="16sp"/>

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/ll_resume"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:visibility="visible">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:background="#FFFFFF">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center">

                <CheckBox
                    android:id="@+id/cb_position"
                    style="@style/rb_search_title"
                    android:text="地點"/>
            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center">

                <CheckBox
                    android:id="@+id/cb_experience"
                    style="@style/rb_search_title"
                    android:text="經驗"/>
            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center">

                <CheckBox
                    android:id="@+id/cb_education"
                    style="@style/rb_search_title"
                    android:text="學歷"/>
            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center">

                <CheckBox
                    android:id="@+id/cb_more"
                    style="@style/rb_search_title"
                    android:text="更多"/>
            </LinearLayout>

        </LinearLayout>

        <View
            android:id="@+id/line"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#dcdcdc"/>


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="30dp"
                    android:background="@color/color_home_back"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:paddingRight="15dp"
                    android:paddingLeft="15dp">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:orientation="horizontal"
                        android:layout_weight="1"
                        android:layout_height="wrap_content">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="共 "
                        android:textColor="@color/color_home_gray_text"
                        android:textSize="12sp"/>

                    <TextView
                        android:id="@+id/tv_resume_total"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textColor="@color/color_resume_blue_txt"
                        android:textSize="12sp"/>

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text=" 份簡歷"
                        android:textColor="@color/color_home_gray_text"
                        android:textSize="12sp"/>
                    </LinearLayout>
                    <TextView
                        android:id="@+id/tv_search_save"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="儲存搜尋條件"
                        android:textColor="@color/color_resume_blue_txt"
                        android:textSize="12sp"/>
                </LinearLayout>

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/rv_resume_list"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scrollbars="vertical"/>

                <LinearLayout
                    android:id="@+id/ll_empty_search"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:gravity="center"
                        android:text="沒有搜尋到符合的資訊"
                        android:textColor="@color/color_home_gray_text"
                        android:textSize="16sp"/>

                </LinearLayout>
            </LinearLayout>

            <FrameLayout
                android:id="@+id/frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="gone"/>
        </RelativeLayout>

    </LinearLayout>


</LinearLayout>

3.include_resume_search_result_title引用佈局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="@color/color_blue"
    android:orientation="horizontal">


    <!--<com.risfond.rnss.widget.ClearEditText-->
        <!--android:id="@+id/et_resume_search"-->
        <!--android:layout_width="0dp"-->
        <!--android:layout_height="30dp"-->
        <!--android:layout_gravity="center_vertical"-->
        <!--android:layout_marginLeft="15dp"-->
        <!--android:layout_marginRight="15dp"-->
        <!--android:layout_weight="1"-->
        <!--android:background="@drawable/bg_home_search"-->
        <!--android:drawableLeft="@mipmap/home_search"-->
        <!--android:drawablePadding="5dp"-->
        <!--android:gravity="center_vertical"-->
        <!--android:hint="簡歷搜尋(多個關鍵字用空格分隔)"-->
        <!--android:imeOptions="actionSearch"-->
        <!--android:inputType="text"-->
        <!--android:paddingLeft="10dp"-->
        <!--android:paddingRight="5dp"-->
        <!--android:textColor="@color/color_white_real"-->
        <!--android:textColorHint="@color/color_resume_input_bg"-->
        <!--android:textSize="12sp"/>-->

    <!--<TextView-->
        <!--android:id="@+id/tv_search_cancel"-->
        <!--android:layout_width="wrap_content"-->
        <!--android:layout_height="match_parent"-->
        <!--android:layout_marginRight="15dp"-->
        <!--android:gravity="center"-->
        <!--android:padding="5dp"-->
        <!--android:text="取消"-->
        <!--android:textColor="@color/color_white"-->
        <!--android:textSize="14sp"/>-->
    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:layout_marginLeft="15sp"
        android:layout_marginRight="15sp"
        android:layout_gravity="center_vertical"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="horizontal"
            android:layout_height="wrap_content">
            <LinearLayout
                android:layout_width="match_parent"
                android:orientation="horizontal"
                android:layout_weight="1"
                android:background="@drawable/bg_home_search"
                android:layout_height="wrap_content">
                <CheckBox
                    android:id="@+id/cb_whole"
                    style="@style/rb_search_title_all"
                    android:text="全部"/>

                <View
                    android:layout_width="1sp"
                    android:layout_gravity="center"
                    android:background="@color/color_white"
                    android:layout_height="15sp"></View>
                <com.risfond.rnss.widget.ClearEditText
                    android:id="@+id/et_resume_search"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:layout_weight="1"
                    android:layout_gravity="center_vertical"
                    android:background="@drawable/bg_home_search"
                    android:drawablePadding="5dp"
                    android:gravity="center_vertical"
                    android:hint="簡歷搜尋(多個關鍵字用空格分隔)"
                    android:imeOptions="actionSearch"
                    android:inputType="text"
                    android:paddingLeft="10dp"
                    android:paddingRight="5dp"
                    android:textColor="@color/color_white_real"
                    android:textColorHint="@color/color_resume_input_bg"
                    android:textSize="12sp"/>

                <ImageView
                    android:id="@+id/quick_search_close"
                    android:layout_width="10sp"
                    android:layout_weight="2"
                    android:layout_gravity="center"
                    android:layout_height="10sp"
                    android:paddingRight="10sp"
                    android:src="@mipmap/hiconclose"/>
            </LinearLayout>

            <TextView
                android:id="@+id/tv_search_cancel"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center"
                android:layout_marginLeft="10sp"
                android:paddingRight="0dp"
                android:text="取消"
                android:textColor="@color/color_white"
                android:textSize="12sp"/>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

4.drawable背景

bg_home_search

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <corners android:radius="5dp"/>
    <solid
        android:color="@color/color_home_search"/>

</shape>

bg_rb_search_pic  圖片狀態

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@mipmap/etrigon1" android:state_checked="true"/>
    <item android:drawable="@mipmap/etrigon" android:state_checked="false"/>

</selector>

5.style="@style/rb_search_title" 風格

  <style name="rb_search_title">
        <item name="android:textSize">13sp</item>
        <item name="android:textColor">@drawable/bg_rb_search_txt</item>
        <item name="android:ellipsize">end</item>
        <item name="android:maxLines">1</item>
        <item name="android:button">@null</item>
        <item name="android:background">@null</item>
        <item name="android:drawablePadding">4dp</item>
        <item name="android:paddingLeft">10dp</item>
        <item name="android:paddingRight">10dp</item>
        <item name="android:gravity">center</item>
        <item name="android:drawableRight">@drawable/bg_rb_search_pic</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">match_parent</item>
    </style>

6.顏色選擇器 bg_rb_search_txt

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
  <item android:state_checked="true" android:color="#0E97FF" />
  <item android:state_checked="false" android:color="#323232" />

</selector>

這裡提供幾張圖,向量圖片可以百度搜索,有一個向量圖的庫