@Override
protected void onResume()
{
super.onResume();
getNoteFromFile();
// Make sure that we don't use the link movement method.
// Instead, we need a blend between the arrow key movement (for regular
// navigation) and
// the link movement (so the user can click on links).
// TODO: Might be able to edit this, since we don't care about
// linkifying text
mText.setMovementMethod(new ArrowKeyMovementMethod()
{
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event)
{
// This block is copied and pasted from LinkMovementMethod's
// onTouchEvent (without the part that actually changes the
// selection).
int action = event.getAction();
if (action == MotionEvent.ACTION_UP)
{
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
if (link.length != 0)
{
link[0].onClick(widget);
return true;
}
}
return super.onTouchEvent(widget, buffer, event);
}
});
}
CharFileViewer.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:dungeon-crawl-android
作者:
评论列表
文章目录