【发布时间】:2015-02-19 04:50:16
【问题描述】:
我正在使用 json 解析,我正在从服务器获取响应,在我的响应中它包含一些 html 标签,它显示在我的 listview 中。我在我的 listview 中使用 imageview 和 textview 。如何删除 html 标签?
回复
[
{
"title_tag":"business",
"description":"<p>\r\n\t<strong>Lorem Ipsum<\/strong> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<\/p>\r\n",
"image":"1.jpg"
}
]
我的适配器
public class CustomAdapterAdvertisement extends BaseAdapter{
private Context context;
private ArrayList<HashMap<String,String>> listData;
private AQuery aQuery;
private static final String ADD_NAME="title_tag";
private static final String ADD_DESC="description";
private static final String ADD_IMAGE="image";
public CustomAdapterAdvertisement(Context context,ArrayList<HashMap<String,String>> listData) {
this.context = context;
this.listData=listData;
aQuery = new AQuery(this.context);
}
@Override
public int getCount() {
return listData.size();
}
@Override
public Object getItem(int position) {
return listData.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public String stripHtml(String html) {
return Html.fromHtml(html).toString();
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(context).inflate(R.layout.advertisement_detail, null);
holder.propic = (ImageView) convertView.findViewById(R.id.advertisement_img);
holder.txtproname = (TextView) convertView.findViewById(R.id.txtnameadvertisement);
// holder.txtproid = (TextView) convertView.findViewById(R.id.txtproidsearch);
holder.txtprofilecast = (TextView) convertView.findViewById(R.id.txtadvertisementdescription);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
holder.txtproname.setText(listData.get(position).get(ADD_NAME));
//holder.txtproid.setText(listData.get(position).get(TAG_PROFILE));
holder.txtprofilecast.setText(listData.get(position).get(ADD_DESC));
holder.txtprofilecast.setText(Html.fromHtml("description").toString());
aQuery.id(holder.propic).image(listData.get(position).get(ADD_IMAGE),true,true,0,R.drawable.ic_launcher);
// image parameter : 1 : memory cache,2:file cache,3:target width,4:fallback image
return convertView;
}
class ViewHolder{
ImageView propic;
TextView txtproname;
// TextView txtproid;
TextView txtprofilecast;
}
}
【问题讨论】:
-
为什么要投反对票??我问错了吗?
标签: android html json listview