-3
我從php文件中讀取數據放入一個數組中。我想要在烤麪包中顯示描述,但烤麪包顯示html/php標籤。我如何刪除它?如何在一個烤麪包中顯示一個html/php代碼
News.java
public class News {
int information_id;
int language_id;
String title;
String description;
public int getinformation_id() {
return information_id;
}
public int getlanguage_id() {
return language_id;
}
public String gettitle() {
return title;
}
public String getdescription() {
return description;
}
public void setinformation_id(int information_id) {
this.information_id = information_id;
}
public void setlanguage_id(int language_id) {
this.language_id = language_id;
}
public void settitle(String title) {
this.title = title;
}
public void setdescription(String description) {
this.description = description;
}
}
Main.java
ArrayList<News> news;
public ArrayList<String> infoid, lanid, titlenews, desnews;
JSONObject json_data;
JSONArray jArray;
private void get_news() {
try {
url = "http://www.learnroid.ir/bigshop/get_news.php";
dbGetData = new DbGetData();
new Thread(new Runnable() {
public void run() {
data = dbGetData.getDataFromDB(url);
runOnUiThread(new Runnable() {
@Override
public void run() {
news = parseJSON(data);
}
});
}
}).start();
Toast.makeText(context, "Please wait ....", 5000).show();
} catch (Exception e) {
}
}
public ArrayList<News> parseJSON(String result) {
news = new ArrayList<News>();
try {
jArray = new JSONArray(result);
for (int i = 0; i < jArray.length(); i++) {
json_data = jArray.getJSONObject(i);
n = new News();
information_id = json_data.getString("information_id");
language_id = json_data.getString("language_id");
title = json_data.getString("title");
description = json_data.getString("description");
n.setinformation_id(Integer.parseInt(information_id));
n.setlanguage_id(Integer.parseInt(language_id));
n.settitle(title);
n.setdescription(description);
infoid.add(information_id);
lanid.add(language_id);
titlenews.add(title);
desnews.add(description);
news.add(n);
/* int information_id;
int language_id;
String title;
String description;*/
}
showdata();
size = infoid.size();
Toast.makeText(context, String.valueOf(size), Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
}
return news;
}
//爲得到PHP數據並放入數組列表INFOID,lanid,.......... ...
和我創建從陣列顯示數據的功能
private void showdata() {
Object[] Arraydes = desnews.toArray();
Object[] Arraylan = lanid.toArray();
for(int i = 0; i < Arraydes.length ; i++){
String s = Arraylan[i].toString();
if (s.equals("2")) {
Toast.makeText(context, String.valueOf(Arraydes[i]),Toast.LENGTH_LONG).show();
}
}
數據形式表是:
information_id:6 LANGUAGE_ID:1 標題:熱點新聞 描述:<p>配送信息</P >
但我需要傳遞的信息只用於展示在吐司
我的土司文本是「<p> Delivery Information </p & GT」