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

问题描述:

从我的PreferenceScreen我想在WebView中打开链接而不是浏览器。有任何想法吗?从preferenceScreen中打开WebView而不是浏览器Android

这里是我的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,不打开手机的浏览器。

您应该在您的偏好项目上使用点击侦听器,并在点击时打开您的活动。

以XML

,通过优先更换PreferenceScreen并给它一个关键

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

然后在您的偏好活动,后加载的偏好设置文件:

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

其中myListener的是一个实例一个内部类,它将启动你的活动并通过URL打开额外的数据。

Regards, Stéphane