Answer the question
In order to leave comments, you need to log in
How to make PreferenceFragment (About) like Yandex.Metro?
The question is, how can I add a picture to the PreferenceFragment as it is done in Yandex.Metro (Settings->About)? Maybe there is not PreferenceFragment, but a separate Activity - then how to switch to this activity from PreferenceFragment?
I found options:
1. Add an intent to the Preference with an indication of a separate Activity "About" (It didn't work - I understand how to go to the URL, but I don't understand how to access the Activity)
2. Create a separate layout and register it on the PreferenceScreen via android:layout (It didn't work out - it gives an error)
3. To catch a click on Preference and send it to the desired Activity - it swears at the startActivity line, as I understand it because of "this", but I still don't understand what exactly needs to be specified in this case.
Third option code:
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static class GeneralPreferenceFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
Preference about = (Preference) findPreference("about");
about.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
{
public boolean onPreferenceClick(Preference pref)
{
startActivity(new Intent(this, InfoActivity.class));
return true;
}
});
}
}
Answer the question
In order to leave comments, you need to log in
Yandex.Metro does not use PreferenceFragment. We consider this api to be inconvenient and inflexible. A regular fragment with regular views is used. And, in general, it is justified.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question