0

I have a texSwitcher to which I add two text views (created dynamically using TextView class). I am switching between the child text views using gesture detector. But when the text is large to fit in the current viewable area, the scrolling doesn't work for textswitcher.

When I tried using setTextMovement method of child text views, then the TextSwitcher stopped listening to horizontal swipe gestures.

Has anybody been successful in showing scrollable text views inside a TextSwitcher.

1 Answer 1

2

I solved this problem with creating my own TextSwitcher.

public class MyOwnSwitcher extends ViewSwitcher {
    public MyOwnSwitcher (Context context) {
        super(context);
    }

    public MyOwnSwitcher (Context context, AttributeSet attrs) {
        super(context, attrs);
    }
}

I moved my "onTouchEvent"-Method into that new Class. Then I had to Override the "onInterceptTouchEvent"-Method like that:

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    onTouchEvent(ev);
    return super.onInterceptTouchEvent(ev);
}

I also had to move some of my Fields and Variables from my Activity to that new class. But you can also use methods of your activity too with:

Activity ac = (Activity) this.getContext();

That should return your Activity.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.