android 圖片選擇與刪除並上傳(實際案例)

最近做了個錄入員工信息的功能;

功能要點:

 1. 從相冊選擇圖片並獲取圖片路徑;

2. 拍照保存圖片並獲取路徑;

3. 下拉列表框功能實現;

4. 選擇圖片後圖片的刪除

5. 表單形式上傳數據和文件

 

EmployeesAddActivity.java

@Route(path = Page.ACTIVITY_EMPLOYEES_ADD)
public class EmployeesAddActivity extends BaseActivity implements View.OnClickListener {
    private static final String TAG = "EmployeesAddActivity";
    private Context mContext;
    @BindView(R.id.tv_name)
    EditText tv_name;
    @BindView(R.id.spinner_workType)
    Spinner spinner_workType;
    @BindView(R.id.rg_sex)
    RadioGroup rg_sex;
    @BindView(R.id.rb_male)
    RadioButton rb_male;
    @BindView(R.id.rb_female)
    RadioButton rb_female;
    @BindView(R.id.tv_age)
    TextView tv_age;
    @BindView(R.id.spinner_folk)
    Spinner spinner_folk;

    @BindView(R.id.tv_politicalStatus)
    TextView tv_politicalStatus;
    @BindView(R.id.tv_tel)
    EditText tv_tel;
    @BindView(R.id.tv_webchat)
    EditText tv_webchat;
    @BindView(R.id.tv_nativeAddr)
    EditText tv_nativeAddr;
    @BindView(R.id.tv_address)
    EditText tv_address;

    @BindView(R.id.tv_valid)
    TextView tv_valid;
    @BindView(R.id.tv_issueDate)
    TextView tv_issueDate;
    @BindView(R.id.tv_employee_remarks)
    EditText tv_employee_remarks;
    @BindView(R.id.tv_upload)
    TextView tv_upload;

    @BindView(R.id.rv_health)
    GridView rv_health;

    @BindView(R.id.tv_idCard)
    EditText tv_idCard;
    @BindView(R.id.tv_birthDay)
    TextView tv_birthDay;
    @BindView(R.id.tv_issuingAuthority)
    EditText tv_issuingAuthority;
    @BindView(R.id.tv_healthNum)
    EditText tv_healthNum;
    @BindView(R.id.tv_empPost)
    EditText tv_empPost;
    @BindView(R.id.spinner_techTitle)
    Spinner spinner_techTitle;
    @BindView(R.id.tv_uploadPhoto)
    TextView tv_uploadPhoto;
    @BindView(R.id.gv_photo)
    GridView gv_photo;
    @BindView(R.id.tv_uploadRcolp)
    TextView tv_uploadRcolp;
    @BindView(R.id.gv_rcolp)
    GridView gv_rcolp;
    @BindView(R.id.tv_uploadDrugLic)
    TextView tv_uploadDrugLic;
    @BindView(R.id.rv_drugLic)
    GridView rv_drugLic;
    @BindView(R.id.ll_medical)
    LinearLayout ll_medical;

    private int mYear, mMonth, mDay;
//    private List<ImageView> imageViews = new ArrayList<>();
    String[] folkArr;
    private List<WorkType> folks = new ArrayList<>();
    String[] workTypeArr;
    private List<WorkType> workTypes = new ArrayList<>();
    private List<WorkType> techTtiles = new ArrayList<>();
    private String officeId = "";
    private String status = "";
    private EmployeeBean employeeBean;
    private String cateringType = "";

    @Override
    public void onBeforeSetContentView() {

    }

    @Override
    public int getLayoutResID() {
        return R.layout.activity_employees_add;
    }

    @Override
    protected CharSequence setActionBarTitle() {
        return "添加從業人員";
    }

    @Nullable
    @Override
    public AppBarConfig getAppBarConfig() {
        return mAppBarCompat;
    }

    @Override
    public int setActionBarRightVisibility() {
        return View.VISIBLE;
    }

    @Override
    public CharSequence setActionBarRightText() {
        return "提交";
    }

    @Override
    protected void actionBarRightOnClick() {
        addEmployee();
    }

    @Override
    public void initContentView(@Nullable Bundle savedInstanceState) {
        mContext = EmployeesAddActivity.this;
        tv_valid.setOnClickListener(this);
        tv_issueDate.setOnClickListener(this);
        tv_birthDay.setOnClickListener(this);
        tv_upload.setOnClickListener(this);
        Calendar ca = Calendar.getInstance();
        mYear = ca.get(Calendar.YEAR);
        mMonth = ca.get(Calendar.MONTH);
        mDay = ca.get(Calendar.DAY_OF_MONTH);
        Log.d(TAG,"mYear="+mYear+",mMonth="+mMonth+",mDay="+mDay);
        tv_uploadPhoto.setOnClickListener(this);
        tv_uploadRcolp.setOnClickListener(this);
        tv_uploadDrugLic.setOnClickListener(this);
        rb_male.setChecked(true);
        requestCameraPermission();

    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        if (getIntent().getStringExtra("officeId") != null) {
            officeId = getIntent().getStringExtra("officeId");
        }

        if (getIntent().getStringExtra("from") != null) {
            status = getIntent().getStringExtra("from");
        }

        if (getIntent().getStringExtra("CateringType") != null) {
            cateringType = getIntent().getStringExtra("CateringType");
            Log.e(TAG,"cateringType=="+cateringType);
            if (cateringType.contains("藥品") || cateringType.contains("醫療")) {
                ll_medical.setVisibility(View.VISIBLE);
            } else {
                ll_medical.setVisibility(View.GONE);
            }
        }

        getFolkData();
        getWorkTypeData();
        getTechTitleData();

        if (status.equals("update")) {
            if (getIntent().getSerializableExtra("employeebean") != null) {
                employeeBean = (EmployeeBean) getIntent().getSerializableExtra("employeebean");
                setEmployeeData();
                officeId = employeeBean.getOfficeId();
            }
        }
    }

    private void requestCameraPermission() {
        if (Build.VERSION.SDK_INT >= 23 ) {
//            isPermissionRequested = true;
            ArrayList<String> permissionsList = new ArrayList<>();
            String[] permissions = {
                    Manifest.permission.CAMERA//,
//                    Manifest.permission.WRITE_EXTERNAL_STORAGE,
//                    Manifest.permission.READ_EXTERNAL_STORAGE
            };

            for (String perm : permissions) {
                if (PackageManager.PERMISSION_GRANTED != checkSelfPermission(perm)) {
                    permissionsList.add(perm);
                    // 進入到這裏代表沒有權限.
                }
            }

            if (!permissionsList.isEmpty()) {
                Log.e(TAG,"permissionsList.isEmpty()="+permissionsList.isEmpty());
                requestPermissions(permissionsList.toArray(new String[permissionsList.size()]), 0);
            } else {

            }
        }
    }

    String delEPath = "";
    String delPhotoPath = "";
    String delRecolpPath = "";
    String delDrugPath = "";
    private void setEmployeeData() {
        tv_name.setText(employeeBean.getName());
        String sex = employeeBean.getSex();
        if (!sex.equals("") && sex.equals("男")) {
            rb_male.setChecked(true);
        } else {
            rb_female.setChecked(true);
        }
        tv_age.setText(String.valueOf(employeeBean.getAge()));
        tv_politicalStatus.setText(employeeBean.getPoliticalStatus());
        tv_tel.setText(employeeBean.getTel());
        tv_webchat.setText(employeeBean.getWebchat());
        tv_nativeAddr.setText(employeeBean.getNativeAddr());
        tv_address.setText(employeeBean.getAddress());
        String validStr = employeeBean.getValidDate();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        if (validStr != null) {
            Date validDate = new Date(Long.valueOf(validStr));
            tv_valid.setText(dateFormat.format(validDate));
        }

        String issueDateStr = employeeBean.getIssueDate();
        if (issueDateStr != null) {
            Date issueDate = new Date(Long.valueOf(issueDateStr));
            tv_issueDate.setText(dateFormat.format(issueDate));
        }
        tv_employee_remarks.setText(employeeBean.getRemarks());
        setHealthData();

        tv_birthDay.setText(employeeBean.getBirthDay());
        tv_issuingAuthority.setText(employeeBean.getIssuingAuthority());
        tv_healthNum.setText(employeeBean.getHealthNum());
        tv_idCard.setText(employeeBean.getIdCard());

        setPhotoData();
        tv_empPost.setText(employeeBean.getEmpPost());
        setRcolpData();
        setDrugData();
    }

    private void setHealthData() {
        String healthStr = employeeBean.getPic();

        if (healthStr != null && !healthStr.equals("")) {
            String[] healthArr = healthStr.split(",");
            pathList.add(healthArr[0]);
            if (healthArr.length >1) {
                pathList.add(healthArr[1]);
            }
            ImgGridAdapter imageAdapter = new ImgGridAdapter(mContext,pathList);
            rv_health.setAdapter(imageAdapter);
            count = pathList.size()-1;
            imageAdapter.setOnDelClickListener(new ImgGridAdapter.onDelClickListener() {
                @Override
                public void onItemDelClick(int position) {
                    count = count - 1;
                    Log.e(TAG,"delPath="+pathList.get(position));
                    if (pathList.get(position).startsWith("http")) {
                        delEPath = delEPath+pathList.get(position)+",";
                    }
                    pathList.remove(position);
                    imageAdapter.notifyDataSetChanged();
                }
            });
        }
    }

    private void setPhotoData() {
        String photo = employeeBean.getPhotoUrl();
        if (photo != null && !photo.equals("")) {
            String[] healthArr = photo.split(",");
            photoPathList.add(healthArr[0]);
            if (healthArr.length >1) {
                photoPathList.add(healthArr[1]);
            }

            ImgGridAdapter imageAdapter = new ImgGridAdapter(mContext,photoPathList);
            gv_photo.setAdapter(imageAdapter);
            photoCount = photoPathList.size()-1;
            imageAdapter.setOnDelClickListener(new ImgGridAdapter.onDelClickListener() {
                @Override
                public void onItemDelClick(int position) {
                    photoCount = photoCount - 1;
                    Log.e(TAG,"delPhotoPath="+photoPathList.get(position));
                    if (photoPathList.get(position).startsWith("http")) {
                        delPhotoPath = delPhotoPath + photoPathList.get(position)+",";
                    }
                    photoPathList.remove(position);
                    imageAdapter.notifyDataSetChanged();
                }
            });
        }
    }

    ……
    //其他給圖片類型賦值的方法省略

    /*
    * 獲取民族列表
    *
    * */
    private void getFolkData() {
        HashMap<String, Object> baseParam = WebFrontUtil.getBaseParam();
        baseParam.put("type","folk");
        OkHttpUtil.post(TAG, WebApi.PUNISH_WAY_URL, baseParam, new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                Log.e(TAG,"getFolkData  e="+e);
            }

            @Override
            public void onResponse(String response, int id) {
                Log.e(TAG,"getFolkData  response="+response);
                try {
                    JSONObject object = new JSONObject(response);
                    if ((int)object.get("code") == 200) {
                        JSONArray array = object.getJSONArray("data");
                        folkArr = new String[array.length()];
                        Gson gson = new Gson();
                        for (int i=0;i<array.length();i++) {
                            WorkType workType = gson.fromJson(array.get(i).toString(), WorkType.class);
                            folks.add(workType);
                            folkArr[i] = workType.getLabel();
                        }
                        ArrayAdapter<String> adapter = new ArrayAdapter(mContext,R.layout.punish_spinner_item,folkArr);
                        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                        spinner_folk.setAdapter(adapter);
                        if (status.equals("update")) {
                            int forkIndex = 0;
                            for (int i=0;i<folkArr.length;i++) {
                                if (folkArr[i].equals(employeeBean.getFolk())) {
                                    forkIndex = i;
                                }
                            }
                            spinner_folk.setSelection(forkIndex);
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
    }

    ……
    //其他獲取下拉列表數據的方法省略

    /*
    * 把所有數據保存到EmployeeBean實體類中
    * */
    private EmployeeBean setEmployeeBean() {
        EmployeeBean employeeBeanNew = new EmployeeBean();
        if (employeeBean != null) {
            employeeBeanNew.setId(employeeBean.getId());
        }
        employeeBeanNew.setName(tv_name.getText().toString());

        if (rb_female.isChecked()) {
            employeeBeanNew.setSex("2");
        } else if(rb_male.isChecked()){
            employeeBeanNew.setSex("1");
        }
        String age = tv_age.getText().toString();
        if (age != null && !age.equals("")) {
            employeeBeanNew.setAge(Integer.valueOf(age));
        }
        employeeBeanNew.setTel(tv_tel.getText().toString());
        employeeBeanNew.setNativeAddr(tv_nativeAddr.getText().toString());
        employeeBeanNew.setAddress(tv_address.getText().toString());
        employeeBeanNew.setFolk(String.valueOf(spinner_folk.getSelectedItemPosition()));
        employeeBeanNew.setWorkType(String.valueOf(spinner_workType.getSelectedItemPosition()));
        employeeBeanNew.setValidDate(tv_valid.getText().toString());
        employeeBeanNew.setIdCard(tv_idCard.getText().toString());
        employeeBeanNew.setBirthDay(tv_birthDay.getText().toString());
        employeeBeanNew.setHealthNum(tv_healthNum.getText().toString());
        employeeBeanNew.setIssueDate(tv_issueDate.getText().toString());
        employeeBeanNew.setIssuingAuthority(tv_issuingAuthority.getText().toString());
        employeeBeanNew.setRemarks(tv_employee_remarks.getText().toString());
        employeeBeanNew.setWebchat(tv_webchat.getText().toString());

        employeeBeanNew.setEmpPost(tv_empPost.getText().toString());
        employeeBeanNew.setTechTitle(String.valueOf(spinner_techTitle.getSelectedItemPosition()));
        return employeeBeanNew;
    }

    private void addEmployee() {
        EmployeeBean employeeBean = setEmployeeBean();
        String path="",path1="";
        String pic = "";
        File file = null;
        File file1 = null;
        if (pathList != null && pathList.size() != 0) {
            path = pathList.get(0);
            if (path.startsWith("http")) {
                pic = path;
            } else {
                file = new File(path);
            }
            if (pathList.size()>1) {
                path1 = pathList.get(1);
                if (path1.startsWith("http")) {
                    if (pic.equals("")) {
                        pic = path1;
                    } else {
                        pic = pic+","+path1;
                    }
                } else {
                    file1 = new File(path1);
                }
            }
        }
        employeeBean.setPic(pic);

        File file2 = null;
        File file3 = null;
        File file4 = null;
        File file5 = null;
        if (cateringType.contains("藥品") || cateringType.contains("醫療")) {
            String rcolpUrl = "";
            if (recolpPathList != null && recolpPathList.size() != 0) {
                String path2 = recolpPathList.get(0);
                if (path2.startsWith("http")) {
                    rcolpUrl = path2;
                } else {
                    file2 = new File(path2);
                }
                if (recolpPathList.size()>1) {
                    String path3 = recolpPathList.get(1);
                    if (path3.startsWith("http")) {
                        if (rcolpUrl.equals("")) {
                            rcolpUrl = path1;
                        } else {
                            rcolpUrl = rcolpUrl+","+path3;
                        }
                    } else {
                        file3 = new File(path3);
                    }
                }
            }
            employeeBean.setRcolpUrl(rcolpUrl);

            String drugUrl = "";
            if (drugPathList != null && drugPathList.size() != 0) {
                String path2 = drugPathList.get(0);
                if (path2.startsWith("http")) {
                    drugUrl = path2;
                } else {
                    file4 = new File(path2);
                }
                if (drugPathList.size()>1) {
                    String path3 = drugPathList.get(1);
                    if (path3.startsWith("http")) {
                        if (drugUrl.equals("")) {
                            drugUrl = path1;
                        } else {
                            drugUrl = drugUrl+","+path3;
                        }
                    } else {
                        file5 = new File(path3);
                    }
                }
            }
            employeeBean.setDruglicUrl(drugUrl);
        }

        File file6 = null;
        String photoUrl = "";
        if (photoPathList != null && photoPathList.size() != 0) {
            String path2 = photoPathList.get(0);
            if (path2.startsWith("http")) {
                photoUrl = path2;
            } else {
                file6 = new File(path2);
            }
        }

        employeeBean.setPhotoUrl(photoUrl);
//                FileLoadUtils.uploadFile(employeeBean);
        Map<String, String> baseParam = new HashMap<>();
        if (status.equals("update")) {
            baseParam.put("id",employeeBean.getId());
        }

        baseParam.put("name",employeeBean.getName());
        baseParam.put("office.id",officeId);
        baseParam.put("gender",employeeBean.getSex());
        baseParam.put("age",String.valueOf(employeeBean.getAge()));
        baseParam.put("tel",employeeBean.getTel());
        baseParam.put("idCard",employeeBean.getIdCard());
        baseParam.put("birthDay",employeeBean.getBirthDay());
        baseParam.put("webchat",employeeBean.getWebchat());
        baseParam.put("folk",employeeBean.getFolk());
        baseParam.put("workType",employeeBean.getWorkType());
        baseParam.put("nativeAddr",employeeBean.getNativeAddr());
        baseParam.put("address",employeeBean.getAddress());
        baseParam.put("IssuingAuthority",employeeBean.getIssuingAuthority());
        baseParam.put("issueDate",employeeBean.getIssueDate());
        baseParam.put("healthNum",employeeBean.getHealthNum());
        baseParam.put("validDate",employeeBean.getValidDate());
        baseParam.put("remarks",employeeBean.getRemarks());
        baseParam.put("empPost",employeeBean.getEmpPost());
        baseParam.put("techTitle",employeeBean.getTechTitle());
        if (status.equals("update")) {
            baseParam.put("picUrl",employeeBean.getPic());
            baseParam.put("picDelUrls",delEPath);
            baseParam.put("photoUrl",employeeBean.getPhotoUrl());
            baseParam.put("photoDelUrls",delPhotoPath);
            if (cateringType.contains("藥品") || cateringType.contains("醫療")) {
                baseParam.put("rcolpUrl",employeeBean.getRcolpUrl());
                baseParam.put("rcolpDelUrls",delRecolpPath);
                baseParam.put("druglicUrl",employeeBean.getDruglicUrl());
                baseParam.put("druglicDelUrls",delDrugPath);
            }

        }

        FileLoadUtils.postEmpFile(WebApi.PUNISH_EMPLOYEE_ADD, baseParam,"picArray",file,file1,
                "rcolpArray",file2,file3, "druglicArray",file4,file5,"photoArray",file6, new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                Log.e(TAG,"addEmployee  e="+e);
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String result = FileLoadUtils.getResponseBody(response);
                Log.e(TAG,"addEmployee  result="+result);
                try {
                    JSONObject object = new JSONObject(result);
                    if (object.getInt("code") == 200) {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(mContext,"添加成功",Toast.LENGTH_SHORT).show();
                                finish();
                            }
                        });
                    }
                    response.close();
                } catch (JSONException e) {
                    e.printStackTrace();
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(mContext,"添加失敗",Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            }
        });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_valid:
                new DatePickerDialog(mContext, AlertDialog.THEME_HOLO_DARK, new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
                        tv_valid.setText(dataFormat(i,i1,i2));
                    }
                }, mYear, mMonth, mDay).show();
                break;
            ……
            case R.id.tv_upload:
                pickFile(2001);
                break;
            case R.id.tv_uploadPhoto:
                pickFile(2003);
                break;
            ……
        }
    }

    // 打開系統的文件選擇器
    public void pickFile(int requestCode) {
        FileLoadUtils.showPhotoDialog((Activity) mContext,requestCode);
    }

    int count = 0;
    int photoCount = 0;
    int recolpCount = 0;
    int drugCount = 0;
    private List<String> pathList = new ArrayList<>();
    private List<String> photoPathList = new ArrayList<>();
    private List<String> recolpPathList = new ArrayList<>();
    private List<String> drugPathList = new ArrayList<>();
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 2001 && resultCode == RESULT_OK) {
            Log.e(TAG,"data="+data.getData()+","+data.getDataString());
            if (data == null) {
                return;
            }
            if (count == 2) {
                Toast.makeText(mContext,"最多上傳2張照片",Toast.LENGTH_SHORT).show();
                return;
            }
            String str = FileLoadUtils.handleImageOnKitKat(mContext,data);
            Log.e(TAG,"str="+str);
            str = FileLoadUtils.saveBitmap(mContext,FileLoadUtils.getimage(str));
            pathList.add(str);
            ImgGridAdapter imageAdapter = new ImgGridAdapter(mContext, pathList);
            rv_health.setAdapter(imageAdapter);
            imageAdapter.setOnDelClickListener(new ImgGridAdapter.onDelClickListener() {
                @Override
                public void onItemDelClick(int position) {
                    count = count - 1;
                    Log.e(TAG,"delPath="+pathList.get(position));
                    if (pathList.get(position).startsWith("http")) {
                        delEPath = delEPath+pathList.get(position)+",";
                    }
                    pathList.remove(position);
                    imageAdapter.notifyDataSetChanged();
                }
            });
            count ++;
        } else if (requestCode == 2002 && resultCode == RESULT_OK) {
            Log.e(TAG,"data="+data.getData()+","+data.getDataString());
            if (count == 2) {
                Toast.makeText(mContext,"最多上傳2張照片",Toast.LENGTH_SHORT).show();
                return;
            }
            String str = FileLoadUtils.getCameraData(data);
            Log.e(TAG,"str="+str);
            pathList.add(str);
            ImgGridAdapter imageAdapter = new ImgGridAdapter(mContext, pathList);
            rv_health.setAdapter(imageAdapter);
            rv_health.requestFocus();
            imageAdapter.setOnDelClickListener(new ImgGridAdapter.onDelClickListener() {
                @Override
                public void onItemDelClick(int position) {
                    count = count - 1;
                    Log.e(TAG,"delPath="+pathList.get(position));
                    if (pathList.get(position).startsWith("http")) {
                        delEPath = delEPath+pathList.get(position)+",";
                    }
                    pathList.remove(position);
                    imageAdapter.notifyDataSetChanged();
                }
            });
            count ++;
            ……
        }
    }

    private String dataFormat(int i,int i1,int i2) {
        String dataStr = "";
        if ((i1+1) <10) {
            if (i2 < 10) {
                dataStr=i+"-0"+(i1+1)+"-0"+i2;
            } else {
                dataStr = i+"-0"+(i1+1)+"-"+i2;
            }
        }else {
            if (i2 < 10) {
                dataStr = i+"-"+(i1+1)+"-0"+i2;
            } else {
                dataStr = i+"-"+(i1+1)+"-"+i2;
            }
        }
        return dataStr;
    }
}

activity_employees_add.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@color/color_ffffff"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true"
    android:scrollbars="none"
    android:layout_height="match_parent"
    tools:context=".modules.employees.EmployeesAddActivity">
    <LinearLayout
        android:orientation="vertical"
        android:layout_marginTop="@dimen/px24"
        android:layout_marginHorizontal="@dimen/px26"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:background="@drawable/bg_enforce_border"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="@string/employee_name"
                style="@style/enforce_text_label_style"
                android:layout_gravity="center_vertical"
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"/>
            <EditText
                android:id="@+id/tv_name"
                android:text=""
                android:background="@color/trans"
                android:layout_weight="4"
                android:layout_width="0dp"
                android:gravity="right"
                style="@style/enforce_text_style_padding"
                android:paddingRight="@dimen/px30"
                android:layout_height="wrap_content"/>
        </LinearLayout>
        <LinearLayout
            android:background="@drawable/bg_enforce_border"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="@string/employee_sex"
                style="@style/enforce_text_label_style"
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"/>
            <LinearLayout
                android:gravity="right"
                android:layout_weight="4"
                android:layout_width="0dp"
                android:layout_height="match_parent">
                <RadioGroup
                    android:id="@+id/rg_sex"
                    android:layout_marginRight="@dimen/px30"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="horizontal" >
                    <RadioButton
                        android:id="@+id/rb_male"
                        android:textSize="@dimen/font_14"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:button="@drawable/radio_button_select"
                        android:paddingLeft="@dimen/px30"
                        android:gravity="center"
                        android:text="男" />
                    <RadioButton
                        android:id="@+id/rb_female"
                        android:textSize="@dimen/font_14"
                        android:layout_marginLeft="@dimen/px55"
                        android:paddingLeft="@dimen/px30"
                        android:button="@drawable/radio_button_select"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:text="女" />
                </RadioGroup>
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:background="@drawable/bg_enforce_border"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="@string/employee_age"
                style="@style/enforce_text_label_style"
                android:layout_gravity="center_vertical"
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"/>
            <EditText
                android:id="@+id/tv_age"
                android:text=""
                android:inputType="number"
                android:background="@color/trans"
                android:layout_weight="4"
                android:layout_width="0dp"
                android:gravity="right"
                style="@style/enforce_text_style_padding"
                android:paddingRight="@dimen/px30"
                android:layout_height="wrap_content"/>
        </LinearLayout>
        <LinearLayout
            android:background="@drawable/bg_enforce_border"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="身份證號:"
                style="@style/enforce_text_label_style"
                android:layout_gravity="center_vertical"
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"/>
            <EditText
                android:id="@+id/tv_idCard"
                android:text=""
                android:inputType="number"
                android:background="@color/trans"
                android:layout_weight="4"
                android:layout_width="0dp"
                android:gravity="right"
                style="@style/enforce_text_style_padding"
                android:paddingRight="@dimen/px30"
                android:layout_height="wrap_content"/>
        </LinearLayout>
        <LinearLayout
            android:background="@drawable/bg_enforce_border"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="出生日期:"
                style="@style/enforce_text_label_style"
                android:layout_gravity="center_vertical"
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"/>
            <TextView
                android:id="@+id/tv_birthDay"
                android:text=""
                android:layout_weight="4"
                android:layout_width="0dp"
                android:gravity="right"
                style="@style/enforce_text_style_padding"
                android:paddingRight="@dimen/px30"
                android:layout_height="wrap_content"/>
        </LinearLayout>
        <LinearLayout
            android:background="@drawable/bg_enforce_border"
            android:orientation="vertical"
            android:paddingBottom="@dimen/px30"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="照片:"
                style="@style/enforce_text_label_style"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
            <TextView
                android:id="@+id/tv_uploadPhoto"
                android:gravity="center_horizontal"
                android:background="@drawable/bg_radius_btn_border_examine"
                android:layout_marginHorizontal="@dimen/px30"
                android:text="點擊上傳"
                android:paddingVertical="@dimen/px23"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
            <GridView
                android:id="@+id/gv_photo"
                android:layout_marginHorizontal="@dimen/px30"
                android:numColumns="2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
        </LinearLayout>
        <LinearLayout
            android:background="@drawable/bg_enforce_border"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="@string/office_tel"
                style="@style/enforce_text_label_style"
                android:layout_gravity="center_vertical"
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"/>
            <EditText
                android:id="@+id/tv_tel"
                android:text=""
                android:inputType="phone"
                android:background="@color/trans"
                android:layout_weight="4"
                android:layout_width="0dp"
                android:gravity="right"
                style="@style/enforce_text_style_padding"
                android:paddingRight="@dimen/px30"
                android:layout_height="wrap_content"/>
        </LinearLayout>
        <LinearLayout
            android:background="@drawable/bg_enforce_border"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="@string/employee_webchat"
                style="@style/enforce_text_label_style"
                android:layout_gravity="center_vertical"
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"/>
            <EditText
                android:id="@+id/tv_webchat"
                android:text=""
                android:background="@color/trans"
                android:layout_weight="4"
                android:layout_width="0dp"
                android:gravity="right"
                style="@style/enforce_text_style_padding"
                android:paddingRight="@dimen/px30"
                android:layout_height="wrap_content"/>
        </LinearLayout>
        <LinearLayout
            android:background="@drawable/bg_enforce_border"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="@string/employee_folk"
                style="@style/enforce_text_label_style"
                android:layout_gravity="center_vertical"
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"/>
            <Spinner
                android:id="@+id/spinner_folk"
                android:spinnerMode="dropdown"
                android:dropDownVerticalOffset="@dimen/px100"
                style="@style/punish_text_style_padding"
                android:layout_gravity="center_vertical"
                android:paddingRight="@dimen/px30"
                android:gravity="right"
                android:layout_weight="4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"/>
            <EditText
                android:visibility="gone"
                android:id="@+id/tv_folk"
                android:text=""
                android:background="@color/trans"
                android:layout_weight="4"
                android:layout_width="0dp"
                android:gravity="right"
                style="@style/enforce_text_style"
                android:paddingRight="@dimen/px30"
                android:layout_height="wrap_content"/>
        </LinearLayout>
        
        ……

        <View
            android:layout_marginBottom="@dimen/px24"
            android:background="#cccccc"
            android:layout_width="match_parent"
            android:layout_height="1px"/>
    </LinearLayout>
</ScrollView>

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章