Note that there are some explanatory texts on larger screens.

plurals
  1. POstoring a user selection that stores itself for use on reload in android app
    primarykey
    data
    text
    <p>I've built a dialog that asks the user to pick a city from the list provided when the application first opens. The dialog works perfectly, however I want to store the user's choice so that when the app is opened a second time, it checks to see if the user has already made a selection previously. If they have, it doesn't display the dialog and defines the city variable as their previously chosen preference. And obviously, if they haven't made a selection previously (because its their first time opening the app or for some reason the app couldn't read the stored preference), it displays the dialog.</p> <p>Here's my dialog in case this helps:</p> <pre><code>final CharSequence[] CityChoice = {"Austin", "Dallas/Fort Worth", "Houston", "San Antonio"}; AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); alt_bld.setIcon(R.drawable.icon); alt_bld.setTitle("Select your city"); alt_bld.setSingleChoiceItems(CityChoice, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), "Your city is now set to "+CityChoice[item]+". To change this, go to Menu -&gt; Preferences.", Toast.LENGTH_LONG).show(); dialog.dismiss(); } }); AlertDialog alert = alt_bld.create(); alert.show(); </code></pre> <p>edit: Oh, and by the way, although I'm picking up android programming fairly quickly (at least I think I am haha) I have to admit I'm quite new to it. So the more detailed your response the better. Thanks a ton in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload