Note that there are some explanatory texts on larger screens.

plurals
  1. POWant to remove html tag in my android project
    primarykey
    data
    text
    <p>I am fetching data from website and i am displaying as listview in android,but with the data it shows some html tags also including the data in my listview.</p> <p>Applicationadapter.java</p> <pre><code>public class ApplicationAdapter extends ArrayAdapter&lt;Application&gt; { private List&lt;Application&gt; items; private LayoutInflater inflator; public ApplicationAdapter(Context context, List&lt;Application&gt; items) { super(context, R.layout.activity_row, items); this.items = items; inflator = LayoutInflater.from(getContext()); } @Override public int getCount() { return items.size(); } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; //View v = convertView; if ( convertView == null ) { convertView = inflator.inflate(R.layout.activity_row, null); LayoutInflater li = LayoutInflater.from(getContext()); //convertView = inflator.inflate(R.layout.app_custom_list, null); holder = new ViewHolder(); holder.text1 = (TextView) convertView.findViewById(R.id.text1); holder.chk = (CheckBox) convertView.findViewById(R.id.checkbox); /*holder.chk .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { /*@Override public void onCheckedChanged(CompoundButton view, boolean isChecked) { int getPosition = (Integer) view.getTag(); items.get(getPosition).setSelected(view.isChecked()); } });*/ convertView.setTag(holder); convertView.setTag(R.id.text1, holder.text1); convertView.setTag(R.id.checkbox, holder.chk); }else { holder = (ViewHolder) convertView.getTag(); } Application app = items.get(position); holder.chk.setTag(position); holder.text1.setText(items.get(position).getContent()); //holder.chk.setChecked(items.get(position).isSelected()); if ( app != null ) { TextView titleText = (TextView) convertView.findViewById(R.id.titleTxt); if ( titleText != null ) titleText.setText(Html.fromHtml(app.getContent()).toString()); //titleText.setText(app.getContent()); //holder.chk.setChecked(((View) Html.fromHtml(app.getContent())).isSelected()); } return convertView; } static class ViewHolder { public TextView text1; public CheckBox chk; } //return convertView; } </code></pre> <p>eventhough i used one line for remove the html tag in listview,but i dont know eventhough its shows the html tags like <br> with my listview. my output shows like that in listview hi<code>&lt;br&gt;</code> bye<code>&lt;br&gt;</code>' hello<code>&lt;br&gt;</code>.but i dont want to show that html tags in my listview,how i can solve the problem.</p> <p>Mainactivity.java</p> <pre><code>public class MainActivity extends Activity implements FetchDataListener { private static final int ACTIVITY_CREATE=0; private ProgressDialog dialog; ListView lv; //private ProjectsDbAdapter mDbHelper; //private SimpleCursorAdapter dataAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list_item); //mDbHelper = new ProjectsDbAdapter(this); //mDbHelper.open(); //fillData(); //registerForContextMenu(getListView()); lv =(ListView)findViewById(R.id.list); initView(); } private void initView() { // show progress dialog dialog = ProgressDialog.show(this, "", "Loading..."); String url = "http://dry-brushlands-3645.herokuapp.com/posts.json"; FetchDataTask task = new FetchDataTask(this); task.execute(url); //mDbHelper.open(); //Cursor projectsCursor = mDbHelper.fetchAllProjects(); //startManagingCursor(projectsCursor); // Create an array to specify the fields we want to display in the list (only TITLE) //String[] from = new String[]{ProjectsDbAdapter.KEY_TITLE}; // and an array of the fields we want to bind those fields to (in this case just text1) //int[] to = new int[]{R.id.text1}; /* Now create a simple cursor adapter and set it to display SimpleCursorAdapter projects = new SimpleCursorAdapter(this, R.layout.activity_row, projectsCursor, from, to); setListAdapter(projects); */ // create the adapter using the cursor pointing to the desired data //as well as the layout information /*dataAdapter = new SimpleCursorAdapter( this, R.layout.activity_row, projectsCursor, from, to, 0); setListAdapter(dataAdapter); */ } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. //getMenuInflater().inflate(R.menu.activity_main, menu); super.onCreateOptionsMenu(menu); MenuInflater mi = getMenuInflater(); mi.inflate(R.menu.activity_main, menu); return true; } @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { createProject(); return super.onMenuItemSelected(featureId, item); } private void createProject() { Intent i = new Intent(this, ProjectEditActivity.class); startActivityForResult(i, ACTIVITY_CREATE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); initView(); } @Override public void onFetchComplete(List&lt;Application&gt; data) { // dismiss the progress dialog if ( dialog != null ) dialog.dismiss(); // create new adapter ApplicationAdapter adapter = new ApplicationAdapter(this, data); // set the adapter to list lv.setAdapter(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(); } } </code></pre> <p>i want to show the listview only data,dont need of htmltags</p> <p>I want to know which line is correct if ( titleText != null ) then <code>titleText.setText(Html.fromHtml(app.getContent()).toString());</code> or i want to write like this <code>holder.text1.setText(Html.fromHtml(app.getContent()).toString());</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload