Я получаю название страны от spinner, теперь я хочу установить код страны в соответствии с номером spinner в edittext ... но я не знаю, как установить в соответствии с номером счетчика ...Как установить текст в зависимости от страны в андроиде?
это код (здесь я получаю название страны от блесны):
pmmobile = (EditText) findViewById(R.id.mob);
private void getCountryData(){
StringRequest stringRequest = new StringRequest(DATA_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONObject j = null;
try {
Log.d("Test",response);
JSONArray result = new JSONArray(response);
//Calling method getCountry to get the Country from the JSON Array
getCountry(result);
} catch (JSONException e) {
e.printStackTrace();
}
}
},new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}});
RequestQueue requestQueue = Volley.newRequestQueue(this);
//Adding request to the queue
requestQueue.add(stringRequest);
}
private void getCountry(JSONArray jsonArrayCountry){
//Traversing through all the items in the json array
List<Country> countries = new ArrayList<>();
try {
String country_name, country_code;
JSONObject countries_object;
for (int i = 0; i < jsonArrayCountry.length(); i++) {
countries_object = jsonArrayCountry.getJSONObject(i);
country_code = countries_object.getString("id");
country_name = countries_object.getString("Name");
countries.add(new Country(country_code, country_name));
}
ArrayAdapter countryAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, countries);
pmcountry.setPrompt("Select Country");
pmcountry.setAdapter(countryAdapter);
pmcountry.setAdapter(new NothingSelectedSpinnerAdapter(countryAdapter,
R.layout.contact_spinner_row_nothing_selected,this));
pmcountry.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
} catch (JSONException e) {
Log.e("PMSearchActivity", e.getLocalizedMessage(), e);
}
}
я хочу, чтобы установить код страны pmmobile..kindly помощью нового для Android.
это мой JSON:
[
{
"id": "1",
"Name": "Afghanistan",
"CountryCode": "AF",
"CountryIso": "AFG"
},
{
"id": "2",
"Name": "Albania",
"CountryCode": "AL",
"CountryIso": "ALB"
},
Фактически я хочу сделать код вызова с мобильным номером, я изменю его на код вместо кода страны. Затем я добавлю номер мобильного телефона – user7316606
http://stackoverflow.com/questions/42243097/how-to- make-linearlayout-design-in-android/42243434 # 42243434 в этом u можно увидеть код вызова .. вот как я хочу показать – user7316606