How to call an Activity from a Preference Activity?
I would like to know how I can start an Activity from a Preference Activity.
My Scenario is like :I have an application which display a set of images in a View. It can be 开发者_JS百科GridView, or a Gallery View or a ListView.(The default view will be GridView)
On Pressing Menu, i ll get a preference Menu where i have List Preference of views (GridView/GalleryView/ListView).
On selecting a Particular View my main Activity's View which displays images should change.
I would like to know how i can implement this?I thought of calling my main Activity by an intent which will be invoked on clicking a view in the preference Activity.
Is that possible?
Thanks,
SenStep #1: Write a PreferenceActivity.
Step #2: Have your main activity reload the preference in onResume() and update its UI accordingly.
You do not need to "call an Activity from a Preference Activity?". Your original activity will regain the foreground once the user presses BACK to exit from the PreferenceActivity.
Call the Activity from Preference activity should be like this.
Preference prefereces=findPreference("key");
prefereces.setIntent(new Intent(getApplicationContext(), NextActivity.class));
加载中,请稍侯......
精彩评论