android - How to implement custom spinner -
i want implement 1 custom spinner app items countries name come server. name comes ascending order want want india come @ first row of item.
// country spinner stringrequest sr = new stringrequest(request.method.get, country_url, new response.listener<string>() { @override public void onresponse(string response) { arraylist<string> arr = new arraylist<string>(arrays.aslist(response.trim().split(","))); arr.add(0, "select country"); arrayadapter<string> adapter = new arrayadapter<string>(editdetails6.this, android.r.layout.simple_list_item_1, arr); spinpcountryname.setadapter(adapter);
remove india list, add first position, write following logic this:
arraylist<string> arr = new arraylist<string>(arrays.aslist(response.trim().split(","))); (int = 0; < arr.size(); i++) { if (arr.get(i).equals("india")) { arr.remove(i); } } arr.add(0, "india"); arr.add(0, "select country");
Comments
Post a Comment