开发者

make links to point to a textview android

Hello i want to make like a table of content开发者_如何学Pythons in my app. I have a textview wich i would like to have some links at the top and when the user clicks one of them, he will be forwarded further down in the same textview. How can i accomplish this, i don't know where to look for info, it should be something like:

<a href=”#somePointOnPage”>Go further down</a>


Further down
<a name=”somePointOnPage”></a>

Thanks in advance


You might consider using a WebView and making your content in HTML rather than using a TextView to do this. With the WebView it will work exactly how you want it to already.

To get it working with a TextView you'll have to look into the Linkify class. The trick will be to override the link clicks to call the textView.scrollTo(x,y) method which means you'd have to measure out where all of your breaks are in pixels instead of being able to use tags like in html. Here is another good resource for Linkify in case you want to go this route. And one more

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜