Привет, я пытаюсь использовать модифицированное устройство, все в порядке. Но я получаю такой результат. [[email protected], [email protected]]Получение странного вывода
Вот мой MainActivity
public class MainActivity extends AppCompatActivity {
@Bind(R.id.activity_main_tv_display)
TextView textData;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
}
@OnClick(R.id.activity_main_btn_show)
void press() {
RemoteApi.Factory.getInstance().getModel().enqueue(new Callback<List<Model>>() {
@Override
public void onResponse(Call<List<Model>> call, Response<List<Model>> response) {
textData.setText(String.valueOf(response.body()));
Log.e("--success--", String.valueOf(response.body()));
}
@Override
public void onFailure(Call<List<Model>> call, Throwable t) {
Log.e("--fail--", t.getMessage());
}
});
}
}
Это моя модель
public class Model {
@SerializedName("Title")
@Expose
private String Title;
@SerializedName("Message")
@Expose
private String Message;
@SerializedName("id")
@Expose
private int id;
// getters and setters declare
}
Вот мой интерфейс
public interface RemoteApi {
String BASE_URL = "xyz/";
@GET("api/Cards")
Call<List<Model>> getModel();
class Factory {
public static RemoteApi remoteApi;
public static RemoteApi getInstance() {
Retrofit retrofit = new Retrofit.Builder().addConverterFactory(GsonConverterFactory.create())
.baseUrl(BASE_URL)
.build();
remoteApi = retrofit.create(RemoteApi.class);
return remoteApi;
}
}
}
И мой API выглядит следующим образом
[{
"Title": "xyz",
"Message": "hello",
"id": 1
}, {
"Title": "abc",
"Message": "hello",
"id": 2
}]
Выполнено. Почему -1? – TooManyEduardos
Ой, извините. Это должен быть response.body() – TooManyEduardos