WIDGETS packages\apps\Launcher\src\com\android\launcher2\AppsCustomizeTabHost.java
"
private static final String WIDGETS_TAB_TAG = ""WIDGETS"";
"
Power control packages\apps\Settings\res\values\strings.xml
<string name="gadget_title">Power control</string> 找到Power control的定義
gadget_title packages\apps\Settings\AndroidManifest.xml
"
<receiver android:name="".widget.SettingsAppWidgetProvider""
android:label=""@string/gadget_title""
android:exported=""false""
android:enabled=""@bool/has_powercontrol_widget"">
<intent-filter>
<action android:name=""android.appwidget.action.APPWIDGET_UPDATE"" />
<action android:name=""android.appwidget.action.APPWIDGET_ENABLED"" />
<action android:name=""android.appwidget.action.APPWIDGET_DISABLED"" />
<action android:name=""android.net.wifi.WIFI_STATE_CHANGED"" />
<action android:name=""android.net.conn.BACKGROUND_DATA_SETTING_CHANGED"" />
<action android:name=""android.bluetooth.adapter.action.STATE_CHANGED"" />
<action android:name=""android.location.PROVIDERS_CHANGED"" />
<action android:name=""com.android.sync.SYNC_CONN_STATUS_CHANGED"" />
</intent-filter>
<meta-data android:name=""android.appwidget.provider"" android:resource=""@xml/appwidget_info"" />
</receiver>" 經過定義找到相關的java代碼和xml文件
appwidget_info packages\apps\Settings\res\xml\appwidget_info.xml 經過xml文件找到背景圖片
android:previewImage="@drawable/preview"
preview packages\apps\Settings\res\drawable-nodpi\
preview.png 背景圖片
.widget.SettingsAppWidgetProvider packages\apps\Settings\src\com\android\settings\widget\SettingsAppWidgetProvider.java
private static final int BUTTON_WIFI = 0; 經過Java文件找到這個他的ID
" views.setOnClickPendingIntent(R.id.btn_wifi, getLaunchPendingIntent(context,
BUTTON_WIFI));"
btn_wifi packages\apps\Settings\res\layout\widget.xml 經過ID找到layout文件
"
<LinearLayout
android:id=""@+id/btn_wifi""
android:layout_width=""0dip""
android:layout_weight=""1"" //0
android:layout_height=""match_parent""//0dip
android:paddingTop=""12dp""
android:background=""@drawable/appwidget_button_left""
android:clickable=""true""
android:focusable=""true""
android:orientation=""vertical"">
<ImageView
android:id=""@+id/img_wifi""
android:layout_width=""match_parent""//0dip
android:layout_height=""0dip""
android:layout_weight=""1"" //0
android:scaleType=""center""
/>
<ImageView
android:id=""@+id/ind_wifi""
android:layout_width=""match_parent"" //0dip
android:layout_height=""wrap_content""//0dip
android:scaleType=""fitXY""
/>
</LinearLayout>
<ImageView
android:layout_width=""1dip""//0dip
android:layout_height=""match_parent""//0dip
android:background=""@drawable/appwidget_settings_divider_holo""
/>" 修改layout文件便可