Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Spinner
- android:id="@+id/spinState"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="10dp"
- android:entries="@array/entry"
- />
- private void getCity_State() {
- Call<List<City>> call = AppController.getInstance().getApiInterface().getCity();
- call.enqueue(new Callback<List<City>>() {
- @Override
- public void onResponse(Call<List<City>> call, Response<List<City>> response) {
- if (response.body() != null)
- {
- city = response.body();
- ArrayList<String> City_States = new ArrayList<>();
- for (int i=0;i<city.size();i++)
- {
- City_States.add(city.get(i).getCity_name());
- }
- cityType.setAdapter(new ArrayAdapter<String>(SignUpEventActivity.this,android.R.layout.simple_list_item_1,City_States));
- }
- }
- @Override
- public void onFailure(Call<List<City>> call, Throwable t) {
- }
- });
- }
- public class City {
- @SerializedName("city_name")
- @Expose
- private String city_name;
- @SerializedName("city_id")
- @Expose
- private int city_id;
- public int getCity_id() {
- return city_id;
- }
- public void setCity_id(int city_id) {
- this.city_id = city_id;
- }
- public String getCity_name() {
- return city_name;
- }
- public void setCity_name(String city_name) {
- this.city_name = city_name;
- }
- }
- @GET("city")
- Call<List<City>> getCity();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement