1. Are you ready for the Galaxy S20? Here is everything we know so far!

how do you let the user select a background for the next activity from a list of colors

Discussion in 'Android Development' started by natig, May 25, 2011.

  1. natig

    natig Lurker
    Thread Starter

    I just wanna pass the index of the selected color to the next activity and start it with the selected background like if its zero make bg white etc...
    Thanks in advance!:D

    1. Download the Forums for Android™ app!


  2. uaeHamed

    uaeHamed Newbie

    If the layout has an ID like this <LinearLayout android:id="@+id/laidout"

    Then you point to that layout mlayout= findViewById(R.id.laidout);

    then set the color with the value you passed into the activity


  3. natig

    natig Lurker
    Thread Starter

    thanks man but how about this, there's one activity with a listview of colors like white red green etc... i wanna pass the index of the selected listitem to the next activity so i can set it from there. i think i'm supposed to use starActivityForResult but i cant figure out how it works.
  4. uaeHamed

    uaeHamed Newbie

    check this page Android Applications Tutorial: Intent

    read how to make an explicitintent
    once that works. then you can use the same thing but with a different constructor that also has some info passed with it so you can use in the new class.

    Intent(String action, Uri uri, Context packageContext, Class<?> cls)
    Create an intent for a specific component with a specified action and data.

Share This Page