Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何从首选项活动调用活动?_Android_Preference - Fatal编程技术网

Android 如何从首选项活动调用活动?

Android 如何从首选项活动调用活动?,android,preference,Android,Preference,我想知道如何从偏好活动开始活动。 我的设想是: 我有一个在视图中显示一组图像的应用程序。它可以是GridView、Gallery视图或ListView。(默认视图为GridView) 按Menu,我将获得一个首选项菜单,其中有视图的列表首选项(GridView/GalleryView/ListView) 选择特定视图时,显示图像的“我的主要活动”视图应发生更改。 我想知道我如何才能实现这一点 我想通过单击首选项活动中的视图来调用我的主活动 可能吗 谢谢, Sen步骤1:编写一个首选项活动 步骤2

我想知道如何从偏好活动开始活动。
我的设想是:

我有一个在视图中显示一组图像的应用程序。它可以是GridView、Gallery视图或ListView。(默认视图为GridView)

按Menu,我将获得一个首选项菜单,其中有视图的列表首选项(GridView/GalleryView/ListView)

选择特定视图时,显示图像的“我的主要活动”视图应发生更改。
我想知道我如何才能实现这一点

我想通过单击首选项活动中的视图来调用我的主活动

可能吗

谢谢,
Sen

步骤1:编写一个
首选项活动

步骤2:让您的主要活动在
onResume()
中重新加载首选项,并相应地更新其UI

您不需要“从首选项活动调用活动?”。一旦用户按BACK退出
首选项活动

步骤1:编写
首选项活动
,您的原始活动将重新出现在前台

步骤2:让您的主要活动在
onResume()
中重新加载首选项,并相应地更新其UI


您不需要“从首选项活动调用活动?”。一旦用户按BACK退出
首选项活动

调用,您的原始活动将恢复前台。来自首选项的活动应如下所示

Preference  prefereces=findPreference("key");
 prefereces.setIntent(new Intent(getApplicationContext(), NextActivity.class));

从首选项调用活动活动应如下所示

Preference  prefereces=findPreference("key");
 prefereces.setIntent(new Intent(getApplicationContext(), NextActivity.class));