Android preferences onclick event
You need to set android:key
for the item:
<Preference
android:key="myKey"
android:title="About" />
Then you can do the following in your code:
Preference myPref = (Preference) findPreference("myKey");
myPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
// open browser or intent here
return true;
}
});
to launch a website:
<PreferenceScreen android:title="website">
<intent
android:action="android.intent.action.VIEW"
android:data="http://www.example.com"
/>
</PreferenceScreen>
to launch a specific activity:
<PreferenceScreen android:title="something">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.example.foo"
android:targetClass="com.example.foo.SomeActivity"
/>
</PreferenceScreen>
you can also use "android:mimetype" to set the mimetype.