I have tried to set it with normal setText method but the value are null and the textView are set to blank no word on it,I took the json from API and here's my code -
public class Child extends AppCompatActivity {
TextView mTitle;
TextView mDescription;
TextView mReleased;
ImageView mCover;
TextView mRating;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_child);
GsonBuilder gsonBuilder = new GsonBuilder();
String Obj = getIntent().getStringExtra("movie");
Movie data = gsonBuilder.create().fromJson(Obj, Movie.class);
mTitle = (TextView) findViewById(R.id.title);
mTitle.setText(data.getTitle());
mDescription = (TextView) findViewById(R.id.description);
mDescription.setText(data.getDescription());
mReleased = (TextView) findViewById(R.id.released);
mReleased.setText(data.getReleased());
mCover = (ImageView) findViewById(R.id.cover);
mRating = (TextView) findViewById(R.id.rating);
mRating.setText(data.getRating());
}}
And this is Movie class -
public class Movie {
public String TMDB_IMAGE_PATH = "http://image.tmdb.org/t/p/w500";
private String title;
@SerializedName("poster_path")
private String poster;
@SerializedName("overview")
private String description;
@SerializedName("backdrop_path")
private String released;
private String rating;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPoster() {
return TMDB_IMAGE_PATH + poster;
}
public void setPoster(String poster) {
this.poster = poster;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getReleased() {
return released;
}
public void setReleased(String released) {
this.released = released;
}
public String getRating() {
return rating;
}
public void setRating(String rating) {
this.rating = rating;
}
public static class result {
private List<Movie> results;
public List<Movie> getResults() {
return results;
}
}}
And last this is the detail in MainActivity -
Movie data = movies.get(position);
final Context context = view.getContext();
Intent intent = new Intent(context, Child.class);
GsonBuilder gsonBuilder = new GsonBuilder();
intent.putExtra("movie", gsonBuilder.create().toJson(data, Movie.class));
context.startActivity(intent);