Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法在ViewSwitcher中正确切换视图_Android_Viewswitcher - Fatal编程技术网

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;