Commit a41324295d38312bb7ee84e8cefdb159e5bbf892
1 parent
c2f64dd6c9
Exists in
master
回调接口的使用
Showing
8 changed files
with
132 additions
and
19 deletions
Show diff stats
PersonalCenter/.idea/inspectionProfiles/Project_Default.xml
| File was created | 1 | <component name="InspectionProjectProfileManager"> | |
| 2 | <profile version="1.0"> | ||
| 3 | <option name="myName" value="Project Default" /> | ||
| 4 | <inspection_tool class="AndroidLintValidFragment" enabled="false" level="ERROR" enabled_by_default="false" /> | ||
| 5 | <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false"> | ||
| 6 | <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" /> | ||
| 7 | <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" /> | ||
| 8 | </inspection_tool> | ||
| 9 | </profile> | ||
| 10 | </component> |
PersonalCenter/.idea/inspectionProfiles/profiles_settings.xml
| File was created | 1 | <component name="InspectionProjectProfileManager"> | |
| 2 | <settings> | ||
| 3 | <option name="PROJECT_PROFILE" value="Project Default" /> | ||
| 4 | <option name="USE_PROJECT_PROFILE" value="true" /> | ||
| 5 | <version value="1.0" /> | ||
| 6 | </settings> | ||
| 7 | </component> |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
| 1 | package com.hjx.personalcenter.activity; | 1 | package com.hjx.personalcenter.activity; |
| 2 | 2 | ||
| 3 | import android.content.Intent; | 3 | import android.content.Intent; |
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | import android.support.v7.app.AppCompatActivity; | 5 | import android.support.v7.app.AppCompatActivity; |
| 6 | import android.view.View; | 6 | import android.view.View; |
| 7 | import android.widget.AdapterView; | ||
| 7 | import android.widget.Button; | 8 | import android.widget.Button; |
| 8 | import android.widget.EditText; | 9 | import android.widget.EditText; |
| 9 | import android.widget.TextView; | 10 | import android.widget.TextView; |
| 10 | 11 | ||
| 11 | import com.hjx.personalcenter.R; | 12 | import com.hjx.personalcenter.R; |
| 12 | import com.hjx.personalcenter.customdialog.GradeListDialog; | 13 | import com.hjx.personalcenter.customdialog.GradeListDialog; |
| 13 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; | 14 | import com.hjx.personalcenter.customdialog.ProvinceListDialog; |
| 14 | import com.hjx.personalcenter.http.HttpManager; | 15 | import com.hjx.personalcenter.http.HttpManager; |
| 16 | import com.hjx.personalcenter.interfaces.DialogCallBack; | ||
| 15 | 17 | ||
| 16 | /**填写注册信息 熊巍 | 18 | /**填写注册信息 熊巍 |
| 17 | * Created by h on 2017/8/9. | 19 | * Created by h on 2017/8/9. |
| 18 | */ | 20 | */ |
| 19 | 21 | ||
| 20 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener { | 22 | public class RegisterInfoActivity extends AppCompatActivity implements View.OnClickListener,DialogCallBack.CallBack { |
| 21 | private EditText et_username; | 23 | private EditText et_username; |
| 22 | private TextView et_region,et_grade,et_school; | 24 | private TextView et_region,et_grade,et_school; |
| 23 | private Button btn_ok; | 25 | private Button btn_ok; |
| 24 | String[] items; | 26 | String[] items; |
| 25 | 27 | ||
| 26 | @Override | 28 | @Override |
| 27 | protected void onCreate(Bundle savedInstanceState) { | 29 | protected void onCreate(Bundle savedInstanceState) { |
| 28 | super.onCreate(savedInstanceState); | 30 | super.onCreate(savedInstanceState); |
| 29 | setContentView(R.layout.activity_registerinfo); | 31 | setContentView(R.layout.activity_registerinfo); |
| 30 | initView(); | 32 | initView(); |
| 31 | initData(); | 33 | initData(); |
| 32 | initLister(); | 34 | initLister(); |
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | private void initView() { | 37 | private void initView() { |
| 36 | et_username = (EditText) findViewById(R.id.et_username); | 38 | et_username = (EditText) findViewById(R.id.et_username); |
| 37 | et_region = (TextView) findViewById(R.id.et_region); | 39 | et_region = (TextView) findViewById(R.id.et_region); |
| 38 | et_grade = (TextView) findViewById(R.id.et_grade); | 40 | et_grade = (TextView) findViewById(R.id.et_grade); |
| 39 | et_school = (TextView) findViewById(R.id.et_school); | 41 | et_school = (TextView) findViewById(R.id.et_school); |
| 40 | btn_ok = (Button) findViewById(R.id.btn_ok); | 42 | btn_ok = (Button) findViewById(R.id.btn_ok); |
| 41 | 43 | ||
| 42 | 44 | ||
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | private void initData() { | 47 | private void initData() { |
| 46 | items = new String[] { "魏", "蜀", "吴" }; | 48 | items = new String[] { "魏", "蜀", "吴" }; |
| 47 | 49 | ||
| 48 | } | 50 | } |
| 49 | 51 | ||
| 50 | private void initLister() { | 52 | private void initLister() { |
| 51 | et_region.setOnClickListener(this); | 53 | et_region.setOnClickListener(this); |
| 52 | et_grade.setOnClickListener(this); | 54 | et_grade.setOnClickListener(this); |
| 53 | et_school.setOnClickListener(this); | 55 | et_school.setOnClickListener(this); |
| 54 | btn_ok.setOnClickListener(this); | 56 | btn_ok.setOnClickListener(this); |
| 55 | 57 | ||
| 56 | 58 | ||
| 57 | } | 59 | } |
| 58 | 60 | ||
| 59 | @Override | 61 | @Override |
| 60 | public void onClick(View v) { | 62 | public void onClick(View v) { |
| 61 | switch (v.getId()){ | 63 | switch (v.getId()){ |
| 62 | case R.id.et_region: | 64 | case R.id.et_region: |
| 63 | choiseregion(); | 65 | choiseregion(); |
| 64 | break; | 66 | break; |
| 65 | case R.id.et_grade: | 67 | case R.id.et_grade: |
| 66 | choisegrade(); | 68 | choisegrade(); |
| 67 | break; | 69 | break; |
| 68 | case R.id.et_school: | 70 | case R.id.et_school: |
| 69 | break; | 71 | break; |
| 70 | case R.id.btn_ok: | 72 | case R.id.btn_ok: |
| 71 | Intent intent = new Intent(); | 73 | Intent intent = new Intent(); |
| 72 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); | 74 | intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class); |
| 73 | startActivity(intent); | 75 | startActivity(intent); |
| 74 | overridePendingTransition(R.anim.rightin, R.anim.rightout); | 76 | overridePendingTransition(R.anim.rightin, R.anim.rightout); |
| 75 | break; | 77 | break; |
| 76 | } | 78 | } |
| 77 | 79 | ||
| 78 | } | 80 | } |
| 79 | //选择地区 | 81 | //选择地区 |
| 80 | private void choiseregion() { | 82 | private void choiseregion() { |
| 81 | HttpManager.getInstance().provices(RegisterInfoActivity.this); | 83 | HttpManager.getInstance().provices(RegisterInfoActivity.this); |
| 82 | ProvinceListDialog.getInstance().show(getSupportFragmentManager(), "ProvinceListDialog"); | 84 | ProvinceListDialog.getInstance(this).show(getSupportFragmentManager(), "ProvinceListDialog"); |
| 85 | |||
| 83 | } | 86 | } |
| 84 | //选择年级 | 87 | //选择年级 |
| 85 | private void choisegrade() { | 88 | private void choisegrade() { |
| 86 | GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog"); | 89 | GradeListDialog.getInstance().show(getSupportFragmentManager(), "GradeListDialog"); |
| 87 | 90 | ||
| 88 | } | 91 | } |
| 92 | |||
| 93 | @Override | ||
| 94 | public void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id) { | ||
| 95 | |||
| 96 | View gradeView = parent.getChildAt(position); | ||
| 97 | TextView gradeTv = (TextView)gradeView.findViewById(R.id.list_items); | ||
| 98 | et_region.setText(gradeTv.getText().toString()); | ||
| 99 | |||
| 100 | |||
| 101 | } | ||
| 89 | } | 102 | } |
| 90 | 103 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/ProvincesAdapter.java
| File was created | 1 | package com.hjx.personalcenter.adapter; | |
| 2 | |||
| 3 | import android.content.Context; | ||
| 4 | import android.view.View; | ||
| 5 | import android.view.ViewGroup; | ||
| 6 | import android.widget.BaseAdapter; | ||
| 7 | import android.widget.TextView; | ||
| 8 | |||
| 9 | import com.hjx.personalcenter.R; | ||
| 10 | import com.hjx.personalcenter.model.ProvinceInfo; | ||
| 11 | |||
| 12 | import java.util.ArrayList; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * Created by l on 2017/7/18. | ||
| 16 | */ | ||
| 17 | |||
| 18 | public class ProvincesAdapter extends BaseAdapter { | ||
| 19 | ArrayList<ProvinceInfo.ProvincesBean> objects; | ||
| 20 | private Context context; | ||
| 21 | |||
| 22 | public ProvincesAdapter(ArrayList<ProvinceInfo.ProvincesBean> objects, Context context) { | ||
| 23 | this.objects = objects; | ||
| 24 | this.context = context; | ||
| 25 | } | ||
| 26 | |||
| 27 | @Override | ||
| 28 | public int getCount() { | ||
| 29 | return objects.size(); | ||
| 30 | } | ||
| 31 | |||
| 32 | @Override | ||
| 33 | public Object getItem(int position) { | ||
| 34 | return position; | ||
| 35 | } | ||
| 36 | |||
| 37 | @Override | ||
| 38 | public long getItemId(int position) { | ||
| 39 | return position; | ||
| 40 | } | ||
| 41 | |||
| 42 | @Override | ||
| 43 | public View getView(final int position, View convertView, ViewGroup parent) { | ||
| 44 | |||
| 45 | ViewHolder holder = null; | ||
| 46 | |||
| 47 | if (convertView == null) { | ||
| 48 | convertView = View.inflate(context, R.layout.custom_adilog_list_item, null); | ||
| 49 | holder = new ViewHolder(); | ||
| 50 | holder.nameText = (TextView) convertView.findViewById(R.id.list_items); | ||
| 51 | convertView.setTag(holder); | ||
| 52 | } else { | ||
| 53 | holder = (ProvincesAdapter.ViewHolder) convertView.getTag(); | ||
| 54 | } | ||
| 55 | |||
| 56 | holder.nameText.setText(objects.get(position).getRegionName()); | ||
| 57 | |||
| 58 | return convertView; | ||
| 59 | } | ||
| 60 | |||
| 61 | |||
| 62 | static class ViewHolder { | ||
| 63 | TextView nameText; | ||
| 64 | } | ||
| 65 | } | ||
| 66 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/GradeListDialog.java
| 1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
| 5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
| 6 | import android.view.Gravity; | 6 | import android.view.Gravity; |
| 7 | import android.view.LayoutInflater; | 7 | import android.view.LayoutInflater; |
| 8 | import android.view.View; | 8 | import android.view.View; |
| 9 | import android.view.ViewGroup; | 9 | import android.view.ViewGroup; |
| 10 | import android.widget.AdapterView; | 10 | import android.widget.AdapterView; |
| 11 | import android.widget.ArrayAdapter; | 11 | import android.widget.ArrayAdapter; |
| 12 | import android.widget.ListView; | 12 | import android.widget.ListView; |
| 13 | import android.widget.Toast; | 13 | import android.widget.Toast; |
| 14 | 14 | ||
| 15 | import com.hjx.personalcenter.R; | 15 | import com.hjx.personalcenter.R; |
| 16 | import com.mylhyl.circledialog.BaseCircleDialog; | 16 | import com.mylhyl.circledialog.BaseCircleDialog; |
| 17 | import com.mylhyl.circledialog.res.values.CircleDimen; | 17 | import com.mylhyl.circledialog.res.values.CircleDimen; |
| 18 | 18 | ||
| 19 | import java.util.ArrayList; | 19 | import java.util.ArrayList; |
| 20 | 20 | ||
| 21 | /**自定义年级列表对话框 | 21 | /**自定义年级列表对话框 |
| 22 | * Created by h on 2017/8/10. | 22 | * Created by h on 2017/8/10. |
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 25 | public class GradeListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
| 26 | ArrayAdapter listadapter; | 26 | ArrayAdapter listadapter; |
| 27 | ListView listView; | 27 | ListView listView; |
| 28 | ArrayList<String> data = new ArrayList<>(); | 28 | ArrayList<String> data = new ArrayList<>(); |
| 29 | public static GradeListDialog getInstance() { | 29 | public static GradeListDialog getInstance() { |
| 30 | GradeListDialog dialogFragment = new GradeListDialog(); | 30 | GradeListDialog dialogFragment = new GradeListDialog(); |
| 31 | dialogFragment.setCanceledBack(true); | 31 | dialogFragment.setCanceledBack(true); |
| 32 | dialogFragment.setCanceledOnTouchOutside(true); | 32 | dialogFragment.setCanceledOnTouchOutside(true); |
| 33 | dialogFragment.setRadius(CircleDimen.RADIUS); | 33 | dialogFragment.setRadius(CircleDimen.RADIUS); |
| 34 | dialogFragment.setWidth(0.5f); | 34 | dialogFragment.setWidth(0.5f); |
| 35 | dialogFragment.setGravity(Gravity.CENTER); | 35 | dialogFragment.setGravity(Gravity.CENTER); |
| 36 | dialogFragment.setBackgroundColor(Color.WHITE); | 36 | dialogFragment.setBackgroundColor(Color.WHITE); |
| 37 | return dialogFragment; | 37 | return dialogFragment; |
| 38 | } | 38 | } |
| 39 | @Override | 39 | @Override |
| 40 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 40 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
| 41 | 41 | ||
| 42 | return inflater.inflate(R.layout.custom_adilog_gradelist, container, false); | 42 | return inflater.inflate(R.layout.custom_adilog_gradelist, container, false); |
| 43 | } | 43 | } |
| 44 | @Override | 44 | @Override |
| 45 | public void onActivityCreated(Bundle savedInstanceState) { | 45 | public void onActivityCreated(Bundle savedInstanceState) { |
| 46 | super.onActivityCreated(savedInstanceState); | 46 | super.onActivityCreated(savedInstanceState); |
| 47 | listView = (ListView) getView().findViewById(R.id.listadapter); | 47 | listView = (ListView) getView().findViewById(R.id.listadapter); |
| 48 | for (int i=0;i<=50;i++){ | 48 | for (int i=0;i<=50;i++){ |
| 49 | data.add("sss"+i); | 49 | data.add("sss"+i); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data); | 52 | listadapter = new ArrayAdapter(getActivity(),R.layout.custom_adilog_list_item,R.id.list_items,data); |
| 53 | listView.setAdapter(listadapter); | 53 | listView.setAdapter(listadapter); |
| 54 | listView.setOnItemClickListener(this); | 54 | listView.setOnItemClickListener(this); |
| 55 | 55 | ||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | @Override | 58 | @Override |
| 59 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 59 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
| 60 | |||
| 60 | Toast.makeText(getActivity(),"你点击了第"+position+"个",Toast.LENGTH_LONG).show(); | 61 | Toast.makeText(getActivity(),"你点击了第"+position+"个",Toast.LENGTH_LONG).show(); |
| 61 | 62 | ||
| 62 | dismiss(); | 63 | dismiss(); |
| 63 | 64 | ||
| 64 | } | 65 | } |
| 65 | } | 66 | } |
| 66 | 67 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/ProvinceListDialog.java
| 1 | package com.hjx.personalcenter.customdialog; | 1 | package com.hjx.personalcenter.customdialog; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
| 5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
| 6 | import android.view.Gravity; | 6 | import android.view.Gravity; |
| 7 | import android.view.LayoutInflater; | 7 | import android.view.LayoutInflater; |
| 8 | import android.view.View; | 8 | import android.view.View; |
| 9 | import android.view.ViewGroup; | 9 | import android.view.ViewGroup; |
| 10 | import android.widget.AdapterView; | 10 | import android.widget.AdapterView; |
| 11 | import android.widget.ArrayAdapter; | ||
| 12 | import android.widget.ListView; | 11 | import android.widget.ListView; |
| 13 | 12 | ||
| 14 | import com.hjx.personalcenter.R; | 13 | import com.hjx.personalcenter.R; |
| 14 | import com.hjx.personalcenter.adapter.ProvincesAdapter; | ||
| 15 | import com.hjx.personalcenter.db.SaveParam; | 15 | import com.hjx.personalcenter.db.SaveParam; |
| 16 | import com.hjx.personalcenter.http.HttpManager; | 16 | import com.hjx.personalcenter.http.HttpManager; |
| 17 | import com.hjx.personalcenter.interfaces.DialogCallBack; | ||
| 18 | import com.hjx.personalcenter.model.ProvinceInfo; | ||
| 17 | import com.mylhyl.circledialog.BaseCircleDialog; | 19 | import com.mylhyl.circledialog.BaseCircleDialog; |
| 18 | import com.mylhyl.circledialog.res.values.CircleDimen; | 20 | import com.mylhyl.circledialog.res.values.CircleDimen; |
| 19 | 21 | ||
| 20 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
| 21 | 23 | ||
| 22 | /** | 24 | /** |
| 23 | * 自定义年级列表对话框 | 25 | * 自定义年级列表对话框 |
| 24 | * Created by h on 2017/8/10. | 26 | * Created by h on 2017/8/10. |
| 25 | */ | 27 | */ |
| 26 | 28 | ||
| 27 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { | 29 | public class ProvinceListDialog extends BaseCircleDialog implements AdapterView.OnItemClickListener { |
| 28 | ArrayAdapter listadapter; | 30 | private ProvincesAdapter listadapter; |
| 29 | ListView listView; | 31 | private ListView listView; |
| 30 | ArrayList<String> data = new ArrayList<>(); | 32 | private ArrayList<ProvinceInfo.ProvincesBean> data = new ArrayList<>(); |
| 31 | 33 | ||
| 32 | public static ProvinceListDialog getInstance() { | 34 | private DialogCallBack.CallBack mCallBack; |
| 33 | ProvinceListDialog dialogFragment = new ProvinceListDialog(); | 35 | |
| 36 | public ProvinceListDialog(DialogCallBack.CallBack callBack) { | ||
| 37 | this.mCallBack = callBack; | ||
| 38 | } | ||
| 39 | |||
| 40 | public static ProvinceListDialog getInstance(DialogCallBack.CallBack callBack) { | ||
| 41 | ProvinceListDialog dialogFragment = new ProvinceListDialog(callBack); | ||
| 34 | dialogFragment.setCanceledBack(true); | 42 | dialogFragment.setCanceledBack(true); |
| 35 | dialogFragment.setCanceledOnTouchOutside(true); | 43 | dialogFragment.setCanceledOnTouchOutside(true); |
| 36 | dialogFragment.setRadius(CircleDimen.RADIUS); | 44 | dialogFragment.setRadius(CircleDimen.RADIUS); |
| 37 | dialogFragment.setWidth(0.5f); | 45 | dialogFragment.setWidth(0.5f); |
| 38 | dialogFragment.setGravity(Gravity.CENTER); | 46 | dialogFragment.setGravity(Gravity.CENTER); |
| 39 | dialogFragment.setBackgroundColor(Color.WHITE); | 47 | dialogFragment.setBackgroundColor(Color.WHITE); |
| 40 | return dialogFragment; | 48 | return dialogFragment; |
| 41 | } | 49 | } |
| 42 | 50 | ||
| 43 | @Override | 51 | @Override |
| 44 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { | 52 | public View createView(Context context, LayoutInflater inflater, ViewGroup container) { |
| 45 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); | 53 | return inflater.inflate(R.layout.custom_adilog_provicelist, container, false); |
| 46 | } | 54 | } |
| 47 | 55 | ||
| 48 | @Override | 56 | @Override |
| 49 | public void onActivityCreated(Bundle savedInstanceState) { | 57 | public void onActivityCreated(Bundle savedInstanceState) { |
| 50 | super.onActivityCreated(savedInstanceState); | 58 | super.onActivityCreated(savedInstanceState); |
| 51 | listView = (ListView) getView().findViewById(R.id.listadapter); | 59 | listView = (ListView) getView().findViewById(R.id.listadapter); |
| 52 | String provinces = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.PROVINCES); | 60 | String provinces = SaveParam.getInstance().getLoginParam(getActivity(), SaveParam.PROVINCES); |
| 53 | if (provinces != null) { | 61 | if (provinces != null) { |
| 54 | 62 | ||
| 55 | for (int i = 0; i < provinces.split(",").length; i++) { | 63 | for (int i = 0; i < provinces.split(",").length; i++) { |
| 56 | String[] itmt = provinces.split(","); | 64 | ProvinceInfo.ProvincesBean provincesBean = new ProvinceInfo.ProvincesBean(); |
| 57 | data.add(itmt[i] + "省"); | 65 | provincesBean.setRegionName(provinces.split(",")[i] + "省"); |
| 58 | //data.add(i,provinces.replaceAll(",","省")); | 66 | data.add(provincesBean); |
| 59 | |||
| 60 | } | 67 | } |
| 61 | } else { | 68 | } else { |
| 62 | HttpManager.getInstance().provices(getActivity()); | 69 | HttpManager.getInstance().provices(getActivity()); |
| 63 | } | 70 | } |
| 64 | 71 | ||
| 65 | listadapter = new ArrayAdapter(getActivity(), R.layout.custom_adilog_list_item, R.id.list_items, data); | 72 | listadapter = new ProvincesAdapter(data,getActivity()); |
| 66 | listView.setAdapter(listadapter); | 73 | listView.setAdapter(listadapter); |
| 67 | listView.setOnItemClickListener(this); | 74 | listView.setOnItemClickListener(this); |
| 68 | 75 | ||
| 69 | } | 76 | } |
| 70 | 77 | ||
| 71 | @Override | 78 | @Override |
| 72 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 79 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
| 73 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); | 80 | //Toast.makeText(getActivity(), "你点击了第" + position + "个", Toast.LENGTH_LONG).show(); |
| 74 | switch (position){ | 81 | mCallBack.provinceOnItemClick(parent,view,position,id); |
| 75 | |||
| 76 | } | ||
| 77 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/interfaces/DialogCallBack.java
| File was created | 1 | package com.hjx.personalcenter.interfaces; | |
| 2 | |||
| 3 | import android.view.View; | ||
| 4 | import android.widget.AdapterView; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * Created by wei on 2017/8/17. | ||
| 8 | */ | ||
| 9 | |||
| 10 | public class DialogCallBack { | ||
| 11 | public interface CallBack{ | ||
| 12 | void provinceOnItemClick(AdapterView<?> parent, View view, int position, long id); | ||
| 13 | } | ||
| 14 | } | ||
| 15 |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/CountyInfo.java
| 1 | package com.hjx.personalcenter.model; | 1 | package com.hjx.personalcenter.model; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | * Created by h on 2017/8/16. | 6 | * Created by h on 2017/8/16. |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | public class CountyInfo { | 9 | public class CountyInfo { |
| 10 | 10 | ||
| 11 | |||
| 11 | /** | 12 | /** |
| 12 | * status : 100 | 13 | * status : 100 |
| 13 | * message : success | 14 | * message : success |
| 14 | * counties : [{"regionId":210302,"parentId":210300,"regionName":"铁东"},{"regionId":210303,"parentId":210300,"regionName":"铁西"},{"regionId":210304,"parentId":210300,"regionName":"立山"},{"regionId":210311,"parentId":210300,"regionName":"千山"},{"regionId":210321,"parentId":210300,"regionName":"台安"},{"regionId":210323,"parentId":210300,"regionName":"岫岩"},{"regionId":210381,"parentId":210300,"regionName":"海城"}] | 15 | * counties : [{"regionId":210302,"parentId":210300,"regionName":"铁东"},{"regionId":210303,"parentId":210300,"regionName":"铁西"},{"regionId":210304,"parentId":210300,"regionName":"立山"},{"regionId":210311,"parentId":210300,"regionName":"千山"},{"regionId":210321,"parentId":210300,"regionName":"台安"},{"regionId":210323,"parentId":210300,"regionName":"岫岩"},{"regionId":210381,"parentId":210300,"regionName":"海城"}] |
| 15 | */ | 16 | */ |
| 16 | 17 | ||
| 17 | private int status; | 18 | private int status; |
| 18 | private String message; | 19 | private String message; |
| 19 | private List<CountiesBean> counties; | 20 | private List<CountiesBean> counties; |
| 20 | 21 | ||
| 21 | public int getStatus() { | 22 | public int getStatus() { |
| 22 | return status; | 23 | return status; |
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | public void setStatus(int status) { | 26 | public void setStatus(int status) { |
| 26 | this.status = status; | 27 | this.status = status; |
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | public String getMessage() { | 30 | public String getMessage() { |
| 30 | return message; | 31 | return message; |
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | public void setMessage(String message) { | 34 | public void setMessage(String message) { |
| 34 | this.message = message; | 35 | this.message = message; |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | public List<CountiesBean> getCounties() { | 38 | public List<CountiesBean> getCounties() { |
| 38 | return counties; | 39 | return counties; |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | public void setCounties(List<CountiesBean> counties) { | 42 | public void setCounties(List<CountiesBean> counties) { |
| 42 | this.counties = counties; | 43 | this.counties = counties; |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 45 | public static class CountiesBean { | 46 | public static class CountiesBean { |
| 46 | /** | 47 | /** |
| 47 | * regionId : 210302 | 48 | * regionId : 210302 |
| 48 | * parentId : 210300 | 49 | * parentId : 210300 |
| 49 | * regionName : 铁东 | 50 | * regionName : 铁东 |
| 50 | */ | 51 | */ |
| 51 | 52 | ||
| 52 | private int regionId; | 53 | private int regionId; |
| 53 | private int parentId; | 54 | private int parentId; |
| 54 | private String regionName; | 55 | private String regionName; |
| 55 | 56 | ||
| 56 | public int getRegionId() { | 57 | public int getRegionId() { |
| 57 | return regionId; | 58 | return regionId; |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | public void setRegionId(int regionId) { | 61 | public void setRegionId(int regionId) { |
| 61 | this.regionId = regionId; | 62 | this.regionId = regionId; |
| 62 | } | 63 | } |
| 63 | 64 | ||
| 64 | public int getParentId() { | 65 | public int getParentId() { |
| 65 | return parentId; | 66 | return parentId; |
| 66 | } | 67 | } |
| 67 | 68 | ||
| 68 | public void setParentId(int parentId) { | 69 | public void setParentId(int parentId) { |
| 69 | this.parentId = parentId; | 70 | this.parentId = parentId; |
| 70 | } | 71 | } |
| 71 | 72 | ||
| 72 | public String getRegionName() { | 73 | public String getRegionName() { |
| 73 | return regionName; | 74 | return regionName; |
| 74 | } | 75 | } |
| 75 | 76 | ||
| 76 | public void setRegionName(String regionName) { | 77 | public void setRegionName(String regionName) { |
| 77 | this.regionName = regionName; | 78 | this.regionName = regionName; |
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| 80 | } | 81 | } |
| 81 | 82 |