我在我的android应用程序中使用json,实际上在列表视图中它也在我的文本中显示了html标签,我怎样才能只显示文本避免html标签
Mainactivity.java
public class MainActivity extends ListActivity implements FetchDataListener
{
private ProgressDialog dialog;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_list_item);
initView();
}
private void initView()
{
// show progress dialog
dialog = ProgressDialog.show(this, "", "Loading...");
String url = "http://floating-wildwood-1154.herokuapp.com/posts.json";
FetchDataTask task = new FetchDataTask(this);
task.execute(url);
}
@Override
public void onFetchComplete(List<Application> data)
{
// dismiss the progress dialog
if ( dialog != null )
dialog.dismiss();
// create new adapter
ApplicationAdapter adapter = new ApplicationAdapter(this, data);
// set the adapter to list
setListAdapter(adapter);
}
@Override
public void onFetchFailure(String msg)
{
// dismiss the progress dialog
if ( dialog != null )
dialog.dismiss();
// show failure message
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
}
应用适配器.java
public class ApplicationAdapter extends ArrayAdapter<Application>
{
private List<Application> items;
public ApplicationAdapter(Context context, List<Application> items)
{
super(context, R.layout.app_custom_list, items);
this.items = items;
}
@Override
public int getCount()
{
return items.size();
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if ( v == null )
{
LayoutInflater li = LayoutInflater.from(getContext());
v = li.inflate(R.layout.app_custom_list, null);
}
Application app = items.get(position);
if ( app != null )
{
TextView titleText = (TextView) v.findViewById(R.id.titleTxt);
if ( titleText != null )
titleText.setText(app.getContent());
}
return v;
}
}
在我的列表视图中,它的显示如下
你好<br>
朋友们'<br>
'
古德姆'<br>'
它用 html 标签显示,我只想要文本数据,文本必须显示在我的列表视图中。