0
我將一些數據從一個活動傳遞給另一個。所有的數據都可以正常傳遞,但是那裏有一個Spanned數據類型,它根本不工作。 當我將它顯示在第一個活動中時,它可以工作,但是當我在其他活動中顯示它時,它甚至會出現。如何使用意圖傳遞Spanned數據類型數據
我把數據從JSON這樣
public void parseJsonData(final String jsonString) {
try {
jArray = new JSONArray(jsonString);
for(int i=0; i < jArray.length(); i++) {
JSONObject jObject = jArray.getJSONObject(i);
news news1 = new news();
news1.setCategory("Spor");
news1.setTitle(jObject.getString("title"));
news1.setDate(jObject.getString("date"));
news1.setContent(Html.fromHtml(jObject.getString("content")));//Here the data type of Content is Spanned
news1.setShort_content(jObject.getString("short_content"));
Sdatalist.add(news1);
}
if (dialog.isShowing()){
dialog.dismiss();
}
} catch (JSONException e) {
e.printStackTrace();
dialog.dismiss();
}
}
從我的適配器我發送的數據是這樣
myholder.myimageview1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent myIntent = new Intent(mycontext, Detailews.class);
myIntent.putExtra("category", mydatalist.get(position).getCategory());
myIntent.putExtra("title", mydatalist.get(position).getTitle());
myIntent.putExtra("date", mydatalist.get(position).getDate());
myIntent.putExtra("cont", mydatalist.get(position).getContent());
myIntent.putExtra("image", mydatalist.get(position).getImage());
mycontext.startActivity(myIntent);
}
});
而在其他活動我收到這樣的
數據我需要一個人來找到這個bug。 :)幫我出
非常感謝。它醒了。但是有沒有辦法解決跨度損失的問題。 –
@ A-Majeed:如果你將一個CharSequence放入一個跨越的額外部分,並且通過'getCharSequenceExtra()'檢索它,它就不會失去這個跨度。 – CommonsWare
好吧。那很好。現在我懂了。我現在需要使textview可滾動才能看到下面的文本。再一次感謝你。 –