开发者

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,

Sen


Step #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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜