Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.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 从首选项屏幕打开WebView而不是浏览器_Android_Preferenceactivity - Fatal编程技术网

Android 从首选项屏幕打开WebView而不是浏览器

Android 从首选项屏幕打开WebView而不是浏览器,android,preferenceactivity,Android,Preferenceactivity,从我的首选项屏幕,我想在WebView而不是浏览器中打开链接。有什么想法吗 以下是我的xml的一部分: <PreferenceCategory android:title="@string/about"> <PreferenceScreen android:title="@string/eula" android:summary=""> <intent android:actio

从我的首选项屏幕,我想在WebView而不是浏览器中打开链接。有什么想法吗

以下是我的xml的一部分:

 <PreferenceCategory
      android:title="@string/about">
     <PreferenceScreen
            android:title="@string/eula"
            android:summary="">
        <intent android:action="android.intent.action.VIEW"
                android:data="http://www.tara.com/m/EULA.aspx" />
    </PreferenceScreen>

    <PreferenceScreen
            android:title="@string/privacy_policy"
            android:summary="">
        <intent android:action="android.intent.action.VIEW"
                android:data="http://www.tara.com/m/Legal/Privacy.aspx" />
    </PreferenceScreen>
    <PreferenceScreen
            android:title="@string/version"
            android:summary="@string/version_name">
    </PreferenceScreen>

    <PreferenceScreen
            android:title="@string/customer_support"
            android:summary="@string/email_description">
            <intent android:action="com.tara.android.turboweather.EMAIL_ACCUWX"
             />
    </PreferenceScreen>
    <PreferenceScreen
            android:title="@string/branding"
            android:summary="">
    </PreferenceScreen>        
</PreferenceCategory>


因此,URL的位置我想打开Android网络视图,而不是打开手机的浏览器。

您应该在首选项上使用单击侦听器,当它被单击时,打开您的活动

在XMl中,将PreferenceScreen替换为PreferenceScreen并给它一个键

<Preference android:title="About"
            android:summary="Details about the app"
            android:key="aboutPref" />
其中myListener是一个内部类的实例,该类将启动您的活动并将url传递到其他数据中打开

问候,, 圣菲

Preference pref = findPreference( "aboutPref" );
pref.setOnPreferenceClickListener( myListener );