erdomester
Newbie
Hello,
I have a program:
EditPreferences.java: to add preferences
HelloWidget.java: just an intent referring to UpdateService.class
MainActivity.java: for listview, textviews, buttons
UpdateService: for the widget, uploading contents of textviews of the widget
config.xml: xml for the activity
main.xml: xml for the widget
row.xml: xml for two textviews that is part of a listview in config.xml
arrays.xml
strings.xml
preferences.xml
widget_provider.xml
These are my files, but we need just some of them.
When user opens the app there is a Settings button for preferences, where user can choose skins.
I want the app to show a toast message when user clicks a skin.
I put this code into MainActivity.java but there is no toast message at the selection. However if user selects one, then quits app and then opens it again, a toast message appears with the correct text. I know this maybe is because it is in the onCreate() method of the activity? Where should i put this?
Arrays.xml:
I have a program:
EditPreferences.java: to add preferences
HelloWidget.java: just an intent referring to UpdateService.class
MainActivity.java: for listview, textviews, buttons
UpdateService: for the widget, uploading contents of textviews of the widget
config.xml: xml for the activity
main.xml: xml for the widget
row.xml: xml for two textviews that is part of a listview in config.xml
arrays.xml
strings.xml
preferences.xml
widget_provider.xml
These are my files, but we need just some of them.
When user opens the app there is a Settings button for preferences, where user can choose skins.
I want the app to show a toast message when user clicks a skin.
I put this code into MainActivity.java but there is no toast message at the selection. However if user selects one, then quits app and then opens it again, a toast message appears with the correct text. I know this maybe is because it is in the onCreate() method of the activity? Where should i put this?
Code:
preferences = PreferenceManager.getDefaultSharedPreferences(this);
String listpref = preferences.getString("listPref", "n/a");
if (listpref.equals("color1"))
{
Toast.makeText(MainActivity.this, "Black" + listpref, Toast.LENGTH_LONG).show();
}
else if (listpref.equals("color2"))
{
Toast.makeText(MainActivity.this, "Brown" + listpref, Toast.LENGTH_LONG).show();
}
else if (listpref.equals("color3"))
{
Toast.makeText(MainActivity.this, "GoldGreen" + listpref, Toast.LENGTH_LONG).show();
}
Arrays.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="listArray">
<item>Black</item>
<item>Brown</item>
<item>Gold-green</item>
<item>Pink-white</item>
</string-array>
<string-array name="listValues">
<item>color1</item>
<item>color2</item>
<item>color3</item>
<item>color4</item>
</string-array>
</resources>