0

I have an array of strings in my class and a ViewSwitcher in my layout:

        <ViewSwitcher
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/text_view_switcher">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/text"/>

            <WebView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/text_webview">
            </WebView>

I have two buttons - Previous and Next for navigation. When the user taps on Next, I set the text of TextView and WebView to the next element of the string array.

The Problem

I want to achieve the following:

if(string[index].contains("img src")) 
    show the Webview;          
else
    show the textview;

How can I do it? ViewSwitcher.showNext is not doing the job properly. Is there way I can associate which view to switch to using IDs?

Akeshwar Jha
  • 4,516
  • 8
  • 52
  • 91

1 Answers1

0

Although not a solution, but a simple workaround was to remove the ViewSwitcher, and keep both views - TextView and the WebView. Now, based upon the conditions, the visibility of the views could be toggled (GONE or VISIBLE).

Akeshwar Jha
  • 4,516
  • 8
  • 52
  • 91