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?