zoukankan      html  css  js  c++  java
  • 流式布局

    /**
    *
    * @ClassName: MineFragment
    * @Description: 我的首页
    * @author yyz
    * @date 2015-11-3 下午5:41:38
    *
    */

    @SuppressLint("ShowToast")
    public class MineFragment extends Fragment {

    public RequestParams params;
    private LoginVO loginVO;
    private ClinicVO clinicVO;

    public static boolean isShow = true;
    public static boolean noShow = false;

    private boolean Show;

    private boolean isload = true;

    private String version;

    private static boolean checked = true;

    // 获取当前系统时间版本号
    // private String clientVersion = System.currentTimeMillis()+"";//获取当前时间;
    private String clientVersion = "1450406249015";

    private ArrayList<TagItem> mAddTags = new ArrayList<TagItem>();
    // 自定义字典条目
    private RelativeLayout rl_customlabel;
    // 药品、常见疾病、药品单位、用法、频度标签
    FlowLayout tag_layout_commoditycategory, tag_layout_commondiseases, tag_layout_drugunit, tag_layout_usage, tag_layout_frequentness;
    // 药品、常见疾病、药品单位、用法、频度标签 输入框
    private EditText inputLabel_commoditycategory, inputLabel_commondiseases, inputLabel_drugunit, inputLabel_usage, inputLabel_frequentness;
    // 存放 药品标签、常见疾病、单位、用法、频度 的集合
    private ArrayList<SysLableMainVO> sysLableCommodityCategoryList = com.hospital.core.init.Util.getInstance().getLableMain1(com.hospital.core.init.Util.DIC_COMMODITYCATEGORY);
    private ArrayList<SysLableMainVO> sysLableCommonDiseasesList = com.hospital.core.init.Util.getInstance().getLableMain1(com.hospital.core.init.Util.DIC_COMMONDISEASES);
    private ArrayList<SysLableMainVO> sysLableUnitList = com.hospital.core.init.Util.getInstance().getLableMain1(com.hospital.core.init.Util.DIC_USELEVELUNIT);
    private ArrayList<SysLableMainVO> sysLableUsageList = com.hospital.core.init.Util.getInstance().getLableMain1(com.hospital.core.init.Util.DIC_USAGE);
    private ArrayList<SysLableMainVO> sysLableFrequencyList = com.hospital.core.init.Util.getInstance().getLableMain1(com.hospital.core.init.Util.DIC_FREQUENCY);

    public MineFragment() {

    }
    private Handler handler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
    switch (msg.what) {
    case 0:
    // initLayoutCommodityCategory(sysLableCommodityCategoryList);
    break;
    default:
    break;
    }
    }
    };
    @Override
    public void onCreate(Bundle savedInstanceState) {

    setHasOptionsMenu(true);

    super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
    getActivity().getWindow().setSoftInputMode(
    WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

    View rootView = inflater.inflate(R.layout.fragment_mine, container,
    false);

    findView(rootView);

    return rootView;
    }

    private void findView(final View rootView) {
    // 组件
    tv_clinic_name = (TextView) rootView.findViewById(R.id.tv_clinic_name);
    tv_clinic_name_all = (TextView) rootView
    .findViewById(R.id.tv_clinic_name_all);
    tv_registration_number = (TextView) rootView
    .findViewById(R.id.tv_registration_number);
    tv_clinic_principal = (TextView) rootView
    .findViewById(R.id.tv_clinic_principal);
    tv_version = (TextView) rootView.findViewById(R.id.tv_version);
    tv_log_out = (TextView) rootView.findViewById(R.id.tv_log_out);
    ll_mine_customlabel = (LinearLayout) rootView
    .findViewById(R.id.ll_mine_customlabel);
    iv_permit = (ImageView) rootView.findViewById(R.id.iv_permit);
    rl_customlabel = (RelativeLayout) rootView.findViewById(R.id.rl_customlabel);
    // 自定义字典layout
    tag_layout_commoditycategory = (FlowLayout) rootView.findViewById(R.id.tag_layout_commoditycategory);
    tag_layout_commondiseases = (FlowLayout) rootView.findViewById(R.id.tag_layout_commondiseases);
    tag_layout_drugunit = (FlowLayout) rootView.findViewById(R.id.tag_layout_drugunit);
    tag_layout_usage = (FlowLayout) rootView.findViewById(R.id.tag_layout_usage);
    tag_layout_frequentness = (FlowLayout) rootView.findViewById(R.id.tag_layout_frequentness);

    /**
    * 初始化标签
    */
    // 药品标签
    initLabelEditCommodityCategory();
    // 常见疾病标签
    initLabelEditCommonDiseases();
    // 单位标签
    initLabelEditUnit();
    // 用法标签
    initLabelEditUsage();
    // 频度标签
    initLabelEditFrequency();

    // 自定义字典收起展开
    cb_isshow_customlabel = (CheckBox) rootView.findViewById(R.id.cb_isshow_customlabel);
    cb_isshow_customlabel.setOnCheckedChangeListener(new OnCheckedChangeListener() {

    @Override
    public void onCheckedChanged(CompoundButton buttonView,
    boolean isChecked) {
    // TODO Auto-generated method stub
    if (isChecked) {
    // 自定义词典展开
    ll_mine_customlabel.setVisibility(View.VISIBLE);
    } else {
    // 自定义词典收起
    ll_mine_customlabel.setVisibility(View.GONE);
    }
    }
    });
    rl_customlabel.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
    if (checked == true) {
    cb_isshow_customlabel.setChecked(true);
    ll_mine_customlabel.setVisibility(View.VISIBLE);
    checked = false;
    }else {
    cb_isshow_customlabel.setChecked(false);
    ll_mine_customlabel.setVisibility(View.GONE);
    checked = true;
    }
    }
    });

    // 处方不显示价格
    cb_isshow_medicine_price = (CheckBox) rootView.findViewById(R.id.cb_isshow_medicine_price);
    cb_isshow_medicine_price.setOnCheckedChangeListener(new OnCheckedChangeListener() {

    @Override
    public void onCheckedChanged(CompoundButton buttonView,
    boolean isChecked) {
    if (isChecked) {
    // 处方不显示价格
    SharedPreferencesUtil.saveBoolData(getActivity(),"Show", false);
    } else {
    // 处方显示价格
    SharedPreferencesUtil.saveBoolData(getActivity(),"Show", true);
    }
    }
    });
    boolean boolData = SharedPreferencesUtil.getBoolData(getActivity(),
    "Show", Show);
    if (boolData) {
    cb_isshow_medicine_price.setChecked(Show);
    } else {
    cb_isshow_medicine_price.setChecked(!Show);
    }

    chwa_medicine = (AddSubstractIntegerActivity) rootView
    .findViewById(R.id.chwa_medicine);

    rl_feedback = (RelativeLayout) rootView.findViewById(R.id.rl_feedback);
    rl_set_password = (RelativeLayout) rootView.findViewById(R.id.rl_set_password);
    rl_version_update = (RelativeLayout) rootView.findViewById(R.id.rl_version_update);

    initData();

    addlistener();
    }

    /**
    * 药品标签
    */
    private void initLabelEditCommodityCategory(){
    // 输入框添加到FlowLayout中
    inputLabel_commoditycategory = (EditText) LayoutInflater.from(getActivity()).inflate(R.layout.tag_edit_text, null);
    LableUtils.addMedicinalLabel(getActivity(), sysLableCommodityCategoryList,inputLabel_commoditycategory, tag_layout_commoditycategory,ConstantValue.LABEL_COMMODITY);
    LableUtils.initLayoutLables(sysLableCommodityCategoryList, inputLabel_commoditycategory, tag_layout_commoditycategory, ConstantValue.LABEL_COMMODITY);
    }

    /**
    * 常见疾病标签
    */
    private void initLabelEditCommonDiseases(){
    // 输入框添加到FlowLayout中
    inputLabel_commondiseases = (EditText) LayoutInflater.from(getActivity()).inflate(R.layout.tag_edit_text, null);
    LableUtils.addMedicinalLabel(getActivity(), sysLableCommonDiseasesList,inputLabel_commondiseases, tag_layout_commondiseases,ConstantValue.LABEL_DISEASES);
    LableUtils.initLayoutLables(sysLableCommonDiseasesList, inputLabel_commondiseases, tag_layout_commondiseases, ConstantValue.LABEL_DISEASES);
    }

    /**
    * 单位标签
    */
    private void initLabelEditUnit(){
    // 输入框添加到FlowLayout中
    inputLabel_drugunit = (EditText) LayoutInflater.from(getActivity()).inflate(R.layout.tag_edit_text, null);
    LableUtils.addMedicinalLabel(getActivity(), sysLableUnitList, inputLabel_drugunit, tag_layout_drugunit, ConstantValue.LABEL_UNIT);
    LableUtils.initLayoutLables(sysLableUnitList, inputLabel_drugunit, tag_layout_drugunit, ConstantValue.LABEL_UNIT);
    }

    /**
    * 用法标签
    */
    private void initLabelEditUsage(){
    // 输入框添加到FlowLayout中
    inputLabel_usage = (EditText) LayoutInflater.from(getActivity()).inflate(R.layout.tag_edit_text, null);
    LableUtils.addMedicinalLabel(getActivity(), sysLableUsageList, inputLabel_usage, tag_layout_usage, ConstantValue.LABEL_USAGE);
    LableUtils.initLayoutLables(sysLableUsageList, inputLabel_usage, tag_layout_usage, ConstantValue.LABEL_USAGE);
    }

    /**
    * 频度标签
    */
    private void initLabelEditFrequency(){
    // 输入框添加到FlowLayout中
    inputLabel_frequentness = (EditText) LayoutInflater.from(getActivity()).inflate(R.layout.tag_edit_text, null);
    LableUtils.addMedicinalLabel(getActivity(), sysLableFrequencyList, inputLabel_frequentness, tag_layout_frequentness, ConstantValue.LABEL_FREQUENCY);
    LableUtils.initLayoutLables(sysLableFrequencyList, inputLabel_frequentness, tag_layout_frequentness, ConstantValue.LABEL_FREQUENCY);
    }
    // //为输入框添加输入监听
    // inputLabel_frequentness.setOnEditorActionListener(new OnEditorActionListener() {
    //
    // @Override
    // public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    // // TODO Auto-generated method stub
    // if (actionId == EditorInfo.IME_ACTION_DONE) {
    // final String label = inputLabel_frequentness.getText().toString().trim(); // 输入框输入数据
    //
    // final SysLableMainVO sysLableMainVO = new SysLableMainVO();
    // sysLableMainVO.setName(label);
    // //添加的标签分类的prentid
    // sysLableMainVO.setParentId(ConstantValue.LABEL_FREQUENCY);
    // sysLableMainVO.setSort(1);
    // sysLableMainVO.setId("");
    // sysLableMainVO.setClinicId(BaseProtocol.getsClinicVO().getId());
    // sysLableMainVO.setStatus(0);
    // sysLableMainVO.setCode(PinyinUtils.getPinyinjp(label));
    // sysLableMainVO.setBase_version("1111111111111");
    // if(LableUtils.createLable(sysLableMainVO)){
    // String[] newStr = new String[tag_layout_frequentness.getChildCount()+1];
    // /**
    // * 获取 子view的数量 并添加进去
    // */
    // if(label!=null&&!label.equals("")){
    // for(int m = 0;m < tag_layout_frequentness.getChildCount()-1;m++){
    // newStr[m] =((TextView)tag_layout_frequentness.getChildAt(m).
    // findViewById(R.id.text)).getText().toString();//根据 当前 位置查找到 当前 textView中标签 内容
    // }
    //
    // sysLableFrequencyList.add(sysLableMainVO);
    // initLayoutFrequency(false);
    // inputLabel_frequentness.setText("");
    // inputLabel_frequentness.setFocusable(true);
    // inputLabel_frequentness.setFocusableInTouchMode(true);
    // inputLabel_frequentness.requestFocus();
    // }
    // }
    // return true;
    // }
    // return false;
    // }
    // });
    // }
    // private void initLayoutFrequency(boolean bool) {
    // tag_layout_frequentness.removeAllViewsInLayout();
    // /**
    // * 创建 textView数组
    // */
    // final TextView[] textViews = new TextView[sysLableFrequencyList.size()];
    // final TextView[] icons = new TextView[sysLableFrequencyList.size()];
    // for (int i = 0; i < sysLableFrequencyList.size(); i++) {
    // mapFrequencyC = new HashMap<String, Integer>();
    // final int pos = i;
    // final View view = (View) LayoutInflater.from(getActivity()).inflate(R.layout.mine_label_textview,tag_layout_frequentness, false);
    // final TextView text = (TextView) view.findViewById(R.id.text); // 查找到当前textView
    // final TextView icon = (TextView) view.findViewById(R.id.delete_icon); // 查找 到当前 删除小图标
    //
    // SysLableMainVO sysFrequency = sysLableFrequencyList.get(i);
    // final String name = sysFrequency.getName();
    // final String id = sysFrequency.getId();
    //
    // text.setText(name); // 将 已有标签设置成 可选标签
    // textViews[i] = text; // 将当前 textView 赋值给 textView数组
    // icons[i] = icon;
    // //设置 单击事件:遍历 图标,进行相应操作
    // icon.setOnClickListener(new View.OnClickListener() {
    // @Override
    // public void onClick(View v) {
    // for(int j = 0; j < icons.length;j++){
    // if(icon.equals(icons[j])){
    //
    // final SysLableMainVO sysLableMainVO = new SysLableMainVO();
    // //添加的标签分类的prentid
    // sysLableMainVO.setParentId(ConstantValue.LABEL_FREQUENCY);
    // sysLableMainVO.setId(id);
    //
    // if(LableUtils.deleteLable(sysLableMainVO)){
    // // 删除 当前 被点击项
    // tag_layout_frequentness.removeViewAt(j);
    // sysLableFrequencyList.remove(j);
    // initLayoutUnit(false);
    // }
    // }
    // }
    // }
    //
    // });
    // text.setOnClickListener(new View.OnClickListener() {
    // @Override
    // public void onClick(View v) {
    // text.setActivated(!text.isActivated()); // true是激活的
    // if (text.isActivated()) {
    // boolean bResult = doAddText(sysLableFrequencyList.get(pos).getName(), false, pos);
    // text.setActivated(bResult);
    // // 遍历 数据 将图标设置为可见:
    // for (int j = 0; j < textViews.length; j++) {
    // if (text.equals(textViews[j])) {// 非当前 textView
    // icons[j].setVisibility(View.VISIBLE);
    // }
    // }
    // } else {
    // for (int j = 0; j < textViews.length; j++) {
    // icons[j].setVisibility(View.GONE);
    // }
    // }
    // /**
    // * 遍历 textView 满足 已经被选中 并且不是 当前对象的textView 则置为 不选
    // */
    // for (int j = 0; j < textViews.length; j++) {
    // if (!text.equals(textViews[j])) {// 非当前 textView
    // textViews[j].setActivated(false); // true是激活的
    // icons[j].setVisibility(View.GONE);
    // }
    // }
    // }
    // });
    // tag_layout_frequentness.addView(view);
    // }
    // tag_layout_frequentness.addView(inputLabel_frequentness);
    // }

    // // 标签索引文本
    // protected int idxTextTag(String text) {
    // int mTagCnt = mAddTags.size(); // 添加标签的条数
    // for (int i = 0; i < mTagCnt; i++) {
    // TagItem item = mAddTags.get(i);
    // if (text.equals(item.tagText)) {
    // return i;
    // }
    // }
    // return -1;
    // }
    //
    // // 标签添加文本状态
    // private boolean doAddText(final String str, boolean bCustom, int idx) {
    // int tempIdx = idxTextTag(str);
    // if (tempIdx >= 0) {
    // TagItem item = mAddTags.get(tempIdx);
    // item.tagCustomEdit = false;
    // item.idx = tempIdx;
    // return true;
    // }
    // int tagCnt = mAddTags.size(); // 添加标签的条数
    // TagItem item = new TagItem();
    // item.tagText = str;
    // item.tagCustomEdit = bCustom;
    // item.idx = idx;
    // mAddTags.add(item);
    // tagCnt++;
    // return true;
    // }

  • 相关阅读:
    [NOIP2015] 子串 题解
    [NOIP2011] 聪明的质检员 题解
    二进制的一些概念
    [NOIP2012] 借教室 题解
    [POJ3764] The XOR Longest Path 题解
    关于本博客
    【SC-MY限定】让填写问卷星成为自动化!
    JZOJ5833 永恒
    九校联考-DL24凉心模拟Day2总结
    【简解】SP7556 Stock Charts
  • 原文地址:https://www.cnblogs.com/achen0502/p/5233983.html
Copyright © 2011-2022 走看看