如何使applcation的启动图标运行首选项活动?

问题描述:

我想要一个应用程序的启动图标运行应用程序的首选项活动(因为它没有活动,只有一个服务)。如何使applcation的启动图标运行首选项活动?

首选项在res/xml/preferences.xml中定义。

请帮我解决这个问题。

+0

它没有“活化状态”,但你想启动“偏好活动”?有些东西一定是错的,为什么不创建一个“偏好活动”并启动它? – theomega 2012-01-17 09:55:02

您需要为您的喜好(PreferenceActivity)创建活动,添加活动您的清单,并提供适当的意图过滤器如下图所示,通过启动器来运行:

<activity android:name=".MyPreferenceActivity" android:label="Preferences" android:noHistory="true"> 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 
+0

Chris,您需要一个名为PreferenceActivity的Java类来扩展Activity以启动它。如果使用Eclipse,那么在创建新项目时应该为您生成。 – AJcodez 2012-01-17 09:58:56