Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: add TextView helper class which is used to convert from the generated Html #146

Open
AndroidDeveloperLB opened this issue Mar 6, 2018 · 4 comments

Comments

@AndroidDeveloperLB
Copy link

If we wish to only view the content that was saved before on the RTEditText, into TextView, using the normal Html.fromHtml isn't enough, as it doesn't handle lists well, and a lot more tags.

Please add an option to somehow view such content on TextView.

@AndroidDeveloperLB
Copy link
Author

For now, the only workaround is to still use RTEditText, yet extend from it and have it disabled:

class ViewOnlyRtEditText @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : RTEditText(context, attrs, defStyleAttr) {

    init {
        isEnabled = false
        isFocusable = false
        isFocusableInTouchMode = false

    }

    override fun onTouchEvent(event: MotionEvent?): Boolean = false
}

@Saunved
Copy link

Saunved commented Jul 25, 2018

@AndroidDeveloperLB I am new to Kotlin. Would it be possible for you to provide a Java implementation of this if it's not too much trouble?

I have found a different workaround. Instead of extending from RTEditText, you can simply declare it in place of the TextView, set its android:editable="false" and use it as usual in the relevant view by called rtEditText.setRichTextEditing(true, value)

@AndroidDeveloperLB
Copy link
Author

@Saunved I've moved forward to other things.
To learn Kotlin, I usually just converted Java and looked at the result.

What the above means, is:

  1. First line is the various CTORs of the class.
  2. the "init" part is shared between them, so it will run no matter which CTOR is used.
  3. the "onTouchEvent" just returns false.

@Saunved
Copy link

Saunved commented Jul 25, 2018

@AndroidDeveloperLB Thanks for the help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants