Question

i'm using my own ViewSwitcher. It contains two TextViews with the same Layout-Settings.

Here's a part of my Layout:

<MyViewSwitcher
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/textSwitcher"
            android:layout_weight="1"
            android:padding="15dp"
            android:textAlignment="inherit"
            android:clickable="false"
            android:measureAllChildren="true">

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="@+id/text"
                android:id="@+id/textView"
                android:layout_gravity="center"
                android:linksClickable="true"
                android:textIsSelectable="false"
                android:typeface="normal"
                android:textStyle="normal"
                android:scrollbars = "vertical"
                android:fadeScrollbars="false"
                android:textSize="@dimen/textsize"
                android:clickable="true"
                android:focusable="true"
                android:longClickable="false" />
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="@+id/text"
                android:id="@+id/textView2"
                android:layout_gravity="center"
                android:linksClickable="true"
                android:textIsSelectable="false"
                android:typeface="normal"
                android:textStyle="normal"
                android:scrollbars = "vertical"
                android:fadeScrollbars="false"
                android:textSize="@dimen/textsize"
                android:clickable="true"
                android:focusable="true"
                android:longClickable="false" />
        </MyViewSwitcher>

They only differ at "android:id".

My ViewSwitcher is working so far. I implemented that scrolling is enabled and horizontal swipes are detected too.

But there's a problem: When I use the "showNext"-Method of ViewSwitcher, the TextView which appears is not scrollable. If I scroll and go back to my last TextView this one scrolled.

Both Views show Scrollbars when "android:fadeScrollbars" is set on false. It's always the "second" TextView which is not scrollable.

Here's how i change the displayed TextView:

TextView oldView = (TextView) this.getCurrentView();
TextView newView = (TextView) this.getNextView();
//newView.setMovementMethod(new LinkMovementMethod());
newView.setText(text);
this.showNext();

I have the feeling that "showNext" does not give the focus to the next View. But I already tried using "clearFocus" on oldView and "requestFocus" on newView.

Any ideas?

Was it helpful?

Solution

I solved the problem by setting the MovementMethod of "oldView" to null:

TextView oldView= (TextView) this.getCurrentView();
oldView.setMovementMethod(null);

TextView newView = (TextView) this.getNextView();
newView .setMovementMethod(new LinkMovementMethod());
newView .setText(html);

this.showNext();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top