Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8894605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:32:34+00:00 2026-06-14T23:32:34+00:00

i have 2 spinners with 10 values each, now what i want is when

  • 0

i have 2 spinners with 10 values each,
now what i want is when the user selects the 2 values returns a specific picture on another activity called “YourPath”

here is the code for the first activity

private Spinner spinner1, spinner2;
private Button btnSubmit;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.locationlist);


    addListenerOnButton();
    addListenerOnSpinnerItemSelection();

}

public void addListenerOnSpinnerItemSelection() {
    spinner1 = (Spinner) findViewById(R.id.spinner1);
    spinner2 = (Spinner) findViewById(R.id.spinner2);

}

public void addListenerOnButton() {

    spinner1 = (Spinner) findViewById(R.id.spinner1);
    spinner2 = (Spinner) findViewById(R.id.spinner2);
    btnSubmit = (Button) findViewById(R.id.button1);

    btnSubmit.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {

            AlertDialog alertDialog = new AlertDialog.Builder(
                    LocationList.this).create(); // Read Update
            alertDialog.setTitle("Confirm Message");
            alertDialog.setMessage("You are in "
                    + String.valueOf(spinner1.getSelectedItem())
                    + "\nAnd You are going to "
                    + String.valueOf(spinner2.getSelectedItem()));

            alertDialog.setButton("Yes",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                int which) {

                            launchIntent();

                        }
                    });

            alertDialog.setButton2("No",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                int which) {

                        }
                    });

            alertDialog.show();
        }

        private void launchIntent() {
            Intent it = new Intent(LocationList.this, YourPath.class);
            it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(it);
        }

    });

}

}

now do i need a database to do that !!!

do you have any ideas about how can i do that !!!!

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:32:35+00:00Added an answer on June 14, 2026 at 11:32 pm

    You do not necessarily need a database at all. In fact, the only reason you would is if you want to dynamically change the images that are possible for users to end up on “your path”.

    If you can provide all of the images while creating the app, simply put them all in the /Drawable folder, and then you will access the one you want in the YourPath Activity.

    I would grab these values and put them in a variable to use them like this:

    String value1 = spinner1.getSelectedItem().toString();
    String value2 = spinner2.getSelectedItem().toString();
    

    Then, I would stick a couple of string values into the intent you are sending to the YourPath activity. You will do that in the launchIntent method like this:

    private void launchIntent() {
            Intent it = new Intent(LocationList.this, YourPath.class);
            it.putExtra("value1", value1);
            it.putExtra("value2", value2);
            startActivity(it);
        }
    

    Then, in your YourPath class, grab these values like this:

    Intent i = getIntent();
    Bundle extras = i.getExtras();
    
    String value1 = extras.getString("value1");
    String value2 = extras.getString("value2");
    

    You will then do some if-else (or preferably switch) statement to figure out which image to show

    if(value1.equals("somevalue") && value2.equals("othervalue")){
        int imageResource = R.drawable.mypic;
    
        ImageView imageView = (ImageView) findViewById(R.id.myImageView);
        Drawable image = getResources().getDrawable(imageResource);
        imageView.setImageDrawable(image);
    }
    

    Then add your my_path layout file to res/layout folder

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/myImageView"
        ></ImageView>
    </LinearLayout>
    

    You should now be able to access the image view in your myPath activity, just dont forget to set the content view:

    setContentView(R.layout.my_path);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two spinners (day_spin and time_spin) in one Activity . I want to
I have two spinners in an activity, A and B. Each spinner uses an
I have an Activity with 3 spinners. These spinners get their data from a
I have a Main-Activity which displays several spinners. With a Toggle-Button in the Main-Activity
I have a group of spinners <select> input fields and I want to find
I have to parse data from server to spinner. Now I want to delete
My ultimate goal is this: I have two spinners, spinner1, spinner2 , each with
I have two spinners. Country and City. I want to dynamically change the City's
I have an options page with 5 spinners. As the user is logged in
I have one spinner, and I am populating that. I have list of values

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.