从preferenceScreen Android打开WebView而不是浏览器

从我的PreferenceScreen我想在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>

因此,我希望打开Android WebView的URL,而不是打开手机的浏览器.

解决方法

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

在XMl中,用Preference替换PreferenceScreen并给它一个键

<Preference android:title="About"
            android:summary="Details about the app"
            android:key="aboutPref" />

然后在您的首选项活动中,加载首选项文件后:

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

其中myListener是一个内部类的实例,它将启动您的活动并传递url以打开intent意外的额外数据.

问候,斯特凡

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...