首先我必须提到我是 Android 和 Java 的新手。我编写了一个 json http 对象,该对象填充 Serializable 类,并从中填充列表视图,一切正常,但现在我尝试使用来自 Serializable 类的一个字符串填充不同 xml 布局上的文本视图。
可序列化类
public class FeedItem implements Serializable {
private static final long serialVersionUID = 1L;
private int test1;
private String title;
private String date;
private String attachmentUrl;
private String id;
private String content;
private String url;
private String tiitle = "sfsf";
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getAttachmentUrl() {
return attachmentUrl;
}
public void setAttachmentUrl(String attachmentUrl) {
this.attachmentUrl = attachmentUrl;
}
@Override
public String toString() {
return "[ title=" + title + ", date=" + date + "]";
}
public void save(){
FeedItem feed = new FeedItem();
Intent intent = new Intent();
Bundle extras = new Bundle();
intent.putExtra("title", feed);
以及我要填充文本视图的片段类
public void UpdateList(){
TextView infoz = (TextView) getView().findViewById(R.id.infoz);
Intent intent = getActivity().getIntent();
Bundle extras = intent.getExtras();
String title = (String) getActivity().getIntent().getSerializableExtra("title");
Toast.makeText(getActivity(), title, Toast.LENGTH_LONG).show();
}
吐司是空的。