ExampleAppWidgetConfigurepublic class ExampleAppWidgetConfigure extends android.app.Activity The configuration screen for the ExampleAppWidgetProvider widget sample. |
Fields Summary |
---|
static final String | TAG | private static final String | PREFS_NAME | private static final String | PREF_PREFIX_KEY | int | mAppWidgetId | android.widget.EditText | mAppWidgetPrefix | View.OnClickListener | mOnClickListener |
Constructors Summary |
---|
public ExampleAppWidgetConfigure()
super();
|
Methods Summary |
---|
static void | deleteTitlePref(android.content.Context context, int appWidgetId)
| static void | loadAllTitlePrefs(android.content.Context context, java.util.ArrayList appWidgetIds, java.util.ArrayList texts)
| static java.lang.String | loadTitlePref(android.content.Context context, int appWidgetId)
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, 0);
String prefix = prefs.getString(PREF_PREFIX_KEY + appWidgetId, null);
if (prefix != null) {
return prefix;
} else {
return context.getString(R.string.appwidget_prefix_default);
}
| public void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
// Set the result to CANCELED. This will cause the widget host to cancel
// out of the widget placement if they press the back button.
setResult(RESULT_CANCELED);
// Set the view layout resource to use.
setContentView(R.layout.appwidget_configure);
// Find the EditText
mAppWidgetPrefix = (EditText)findViewById(R.id.appwidget_prefix);
// Bind the action for the save button.
findViewById(R.id.save_button).setOnClickListener(mOnClickListener);
// Find the widget id from the intent.
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if (extras != null) {
mAppWidgetId = extras.getInt(
AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
}
// If they gave us an intent without the widget id, just bail.
if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
finish();
}
mAppWidgetPrefix.setText(loadTitlePref(ExampleAppWidgetConfigure.this, mAppWidgetId));
| static void | saveTitlePref(android.content.Context context, int appWidgetId, java.lang.String text)
// Write the prefix to the SharedPreferences object for this widget
SharedPreferences.Editor prefs = context.getSharedPreferences(PREFS_NAME, 0).edit();
prefs.putString(PREF_PREFIX_KEY + appWidgetId, text);
prefs.commit();
|
|