-4
私はアンドロイドで改造2.1を使用しようとしていますが、回答として7回だけ[email protected]を出力します。私は間違って何をしていますか?改造したAndroidの問題2
JSON
[{
"id": "2",
"categories_id": "2",
"title": "समाज",
"featured_news": "0",
"cover_img": "50D5C03F4C476E718D615DEB3240CCB275E027A2.jpg",
"meta_desc": "एक चीन नीतिमा प्रतिवद्ध छौं: अर्थमन्त्री महरा",
"details": "उपप्रधान तथा अर्थमन्त्री कृष्णबहादुर महरासँग नेपालका लागि चीनका नवनियुक्त राजदुत यु होङले आज अर्थमन्त्रालयमा भेटबार्ता गरेकीछन्।",
"status": "1",
"postdate": "2016-11-18 16:45:16"
},
...]
主な活動クラス:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView textView = (TextView) findViewById(R.id.textView);
ApiService api_service = ApiService.retrofit.create(ApiService.class);
final Call<List<PostUpdates>> call = api_service.getUpdates("updates");
call.enqueue(new Callback<List<PostUpdates>>() {
@Override
public void onResponse(Call<List<PostUpdates>> call, Response<List<PostUpdates>> response) {
textView.setText(response.body().toString());
}
@Override
public void onFailure(Call<List<PostUpdates>> call, Throwable t) {
textView.setText(t.getMessage().toString());
}
});
}
ApiServiceインタフェース
public interface ApiService{
String ENDPOINT = "http://localhost/test_api/";
@GET("api/{param}")
Call<List<PostUpdates>> getUpdates(@Path("param") String param);
public final static Retrofit retrofit = new Retrofit.Builder()
.baseUrl(ENDPOINT)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
PostUpdates
public class PostUpdates {
private String id;
private String categoriesId;
private String title;
private String isFeatured;
private String featuredImg;
private String metaDesc;
private String details;
private String status;
private String postdate;
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
/**
*
* @return
* The id
*/
public String getId() {
return id;
}
/**
*
* @param id
* The id
*/
public void setId(String id) {
this.id = id;
}
/**
*
* @return
* The categoriesId
*/
public String getCategoriesId() {
return categoriesId;
}
/**
*
* @param categoriesId
* The categories_id
*/
public void setCategoriesId(String categoriesId) {
this.categoriesId = categoriesId;
}
/**
*
* @return
* The title
*/
public String getTitle() {
return title;
}
/**
*
* @param title
* The title
*/
public void setTitle(String title) {
this.title = title;
}
/**
*
* @return
* The isFeatured
*/
public String getIsFeatured() {
return isFeatured;
}
/**
*
* @param isFeatured
* The is_featured
*/
public void setIsFeatured(String isFeatured) {
this.isFeatured = isFeatured;
}
/**
*
* @return
* The featuredImg
*/
public String getFeaturedImg() {
return featuredImg;
}
/**
*
* @param featuredImg
* The featured_img
*/
public void setFeaturedImg(String featuredImg) {
this.featuredImg = featuredImg;
}
/**
*
* @return
* The metaDesc
*/
public String getMetaDesc() {
return metaDesc;
}
/**
*
* @param metaDesc
* The meta_desc
*/
public void setMetaDesc(String metaDesc) {
this.metaDesc = metaDesc;
}
/**
*
* @return
* The details
*/
public String getDetails() {
return details;
}
/**
*
* @param details
* The details
*/
public void setDetails(String details) {
this.details = details;
}
/**
*
* @return
* The status
*/
public String getStatus() {
return status;
}
/**
*
* @param status
* The status
*/
public void setStatus(String status) {
this.status = status;
}
/**
*
* @return
* The postdate
*/
public String getPostdate() {
return postdate;
}
/**
*
* @param postdate
* The postdate
*/
public void setPostdate(String postdate) {
this.postdate = postdate;
}
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
アンドロイドアプリは、この結果 screenshot here
オブジェクトのメモリアドレスを表示します – droidev
ゲッターメソッドを使用して応答内の値を表示します – droidev