0

Hi I create an adapter in my recyclerview applications. so I display my string files in my textview but when I try to set my adapter to display my string files in "Description" compatible with html codes, then my text disappear. So could you help me what is wrong? thanks alot.

@Override
public void onBindViewHolder(final FlowerViewHolder holder, int position) {

    holder.mImage.setImageResource(mFlowerList.get(position).getFlowerImage());
    holder.mTitle.setText(mFlowerList.get(position).getFlowerName());
    holder.mCardView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent mIntent = new Intent(mContext, DetailActivity.class);
            mIntent.putExtra("Title", mFlowerList.get(holder.getAdapterPosition()).getFlowerName());
            mIntent.putExtra("Description", showHtml (mFlowerList.get(holder.getAdapterPosition()).getFlowerDescription()));
            mIntent.putExtra("Image", mFlowerList.get(holder.getAdapterPosition()).getFlowerImage());
            mContext.startActivity(mIntent);
        }

        private String showHtml(String description) {
            return null;
        }
    });



}

@Override
public int getItemCount() {
    return mFlowerList.size();
}

}

e.zver
  • 31
  • 5
  • Why `showHtml(String description)` method returns null? – Dumbo Feb 08 '18 at 15:29
  • I am newbie sorry when I create "showHtml " it appers null so I dont know what is my mistake. – e.zver Feb 08 '18 at 15:33
  • There your description disappears – Dumbo Feb 08 '18 at 15:35
  • how could I correct it? – e.zver Feb 08 '18 at 15:48
  • If you want to convert html to formatted text then visit [this answer](https://stackoverflow.com/a/2116191/7721510). – CeH9 Feb 08 '18 at 15:48
  • Replace `null` with `Html.fromHtml(description)` if description is `HTML` code – Dumbo Feb 08 '18 at 15:50
  • private Spanned showHtml(String Description) { return Html.fromHtml(Description); it doesntwork. is there any solution? or isn't it possible display html in recyclerview? so I couldnt any article about it. – e.zver Feb 08 '18 at 15:57
  • You could set it to `TextView` on `RecyclerView` using this method (top answer): textviewhttps://stackoverflow.com/questions/2116162/how-to-display-html-in-textview# . `Html.fromHtml(string)` is working differently on different type of android version. – Dumbo Feb 09 '18 at 07:32

0 Answers0