Android 无法在ViewSwitcher中正确切换视图
在我的类中有一个字符串数组,在我的布局中有一个Android 无法在ViewSwitcher中正确切换视图,android,viewswitcher,Android,Viewswitcher,在我的类中有一个字符串数组,在我的布局中有一个视图切换器: <ViewSwitcher android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/text_view_switcher"> <TextView and
视图切换器
:
<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>
我怎么做<代码>视图切换器。showNext未正确执行此操作。有没有办法使用IDs将切换到哪个视图关联起来?虽然不是一个解决方案,但一个简单的解决方法是删除
视图切换器
,并保留两个视图-文本视图
和网络视图
。现在,根据条件,可以切换视图的可见性(GONE
或VISIBLE
)
if(string[index].contains("img src"))
show the Webview;
else
show the textview;