Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://raw.githubusercontent.com/lutangar/cities.json/master/")
.addConverterFactory(GsonConverterFactory.create())
.build();
MessagesApi messagesApi = retrofit.create(MessagesApi.class);
Call<List<Message>> messages = messagesApi.messages();
messages.enqueue(new Callback<List<Message>>() {
@Override
public void onResponse(Call<List<Message>> call, Response<List<Message>> response) {
if (response.isSuccessful()) {
Log.d("TAAG", "Response.body().size()=" + response.body().size());
for (int i = 0; i < response.body().size(); i++ ){
Log.d("TAAG", "text" + response.body().get(i).getName());
arrayList.add(response.body().get(i).getName());
};
mAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
mAutoCompleteTextView.setAdapter(new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_dropdown_item_1line, arrayList));
} else {
}
}
@Override
public void onFailure(Call<List<Message>> call, Throwable t) {
Toast.makeText(MainActivity.this,"ошибка при получении удаленных данных",Toast.LENGTH_LONG).show();
}
});