Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to make interconnceted edittext for ex. when select country we get state name like that.

What I have tried:

   private void makeJsonObjectRequest() {

        // showpDialog();

        JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
                urlJsonObj, null, new Response.Listener<JSONObject>() {

            @Override
            public void onResponse(JSONObject response) {
                Log.d(TAG, response.toString());
                Toast.makeText(Facebook.this, response.toString(), Toast.LENGTH_SHORT).show();

                try {

                      JSONArray data = response.getJSONArray("data");
                       Log.d("data",data.toString());
                    for (int i = 0; i < response.length(); i++) {
                        JSONObject bigdata = data.getJSONObject(i);
                        Log.d("bigdata:", bigdata.toString());

                        String univ_name = bigdata.getString("university_name");
                        Log.d("univename", univ_name);




                        Universitylist = new ArrayList<>();
//                        for (University university : response.getData()) {
//                            if (!university.getUniversityName().isEmpty()) {
                                Universitylist.add(bigdata.toString(Integer.parseInt("")));
                                //  Log.d("fguniversity",Universitylist.toString());



                            if (Universitylist.size() > 0) {
                                universityAdapter = new ArrayAdapter<String>(Facebook.this, R.layout.spinner_item, Universitylist);
                                universityAdapter.setDropDownViewResource(R.layout.spinner_itemforchild);

                                fguniversity.setOnClickListener(new AdapterView.OnClickListener() {

                                    public void onClick(View v) {
                                        new AlertDialog.Builder(Facebook.this)
                                                .setTitle("Select University")
                                                .setAdapter(universityAdapter, new DialogInterface.OnClickListener() {

                                                    public void onClick(DialogInterface dialog, int which) {
                                                        fguniversity.setText(Universitylist.get(which).toString());
                                                        if (universityAdapter.getItem(which).equals("RGPV")) {
                                                            u_id = "1";
                                                        }


                                                        //   fetchCollegeFromServerByUniversityName(u_id);
                                                        dialog.dismiss();
                                                    }
                                                }).create().show();
                                    }
                                });
                            }
                        }

                } catch (JSONException e) {
                    e.printStackTrace();
                    Toast.makeText(getApplicationContext(),
                            "Error: " + e.getMessage(),
                            Toast.LENGTH_LONG).show();
                }
                //  hidepDialog();
            }
        }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {
                VolleyLog.d(TAG, "Error: " + error.getMessage());
                Toast.makeText(getApplicationContext(),
                        error.getMessage(), Toast.LENGTH_SHORT).show();
                // hide the progress dialog
                // hidepDialog();
            }
        });

        // Adding request to request queue
        AppController.getInstance().addToRequestQueue(jsonObjReq);
    }

    public class Universitydata {

        @SerializedName("data")
        List<University> mData;



        public List<University> getData() {
            return mData;
        }

        public void setData(List<University> data) {
            mData = data;
        }

    }
Posted
Comments
Richard MacCutchan 2-Aug-17 3:37am    
And what is the problem?
David Crow 2-Aug-17 9:26am    
What is an "interconnceted edittext?" What do you mean by "when select country we get state name like that?"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900