on button click it updates the second activity spinner and textviews











up vote
0
down vote

favorite












I am creating an app which has 2 activities. Main activity has three buttons with different movie genre. On clicking any of the three buttons it should go to the second activity which consists of:



2 spinners: to display movie name and 1 for movie time
2 textview to display movie rating and casts
textview to open calendar



the spinners should be updated depending on the movie genre selected as well as the textviews for movie rating and cast



So far i have created the XML for main activity and class to make an arraylist to hold the movie details. I also did intent to go to next page but i am confused on how to display movies in spinner only for selected genre.










share|improve this question


























    up vote
    0
    down vote

    favorite












    I am creating an app which has 2 activities. Main activity has three buttons with different movie genre. On clicking any of the three buttons it should go to the second activity which consists of:



    2 spinners: to display movie name and 1 for movie time
    2 textview to display movie rating and casts
    textview to open calendar



    the spinners should be updated depending on the movie genre selected as well as the textviews for movie rating and cast



    So far i have created the XML for main activity and class to make an arraylist to hold the movie details. I also did intent to go to next page but i am confused on how to display movies in spinner only for selected genre.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am creating an app which has 2 activities. Main activity has three buttons with different movie genre. On clicking any of the three buttons it should go to the second activity which consists of:



      2 spinners: to display movie name and 1 for movie time
      2 textview to display movie rating and casts
      textview to open calendar



      the spinners should be updated depending on the movie genre selected as well as the textviews for movie rating and cast



      So far i have created the XML for main activity and class to make an arraylist to hold the movie details. I also did intent to go to next page but i am confused on how to display movies in spinner only for selected genre.










      share|improve this question













      I am creating an app which has 2 activities. Main activity has three buttons with different movie genre. On clicking any of the three buttons it should go to the second activity which consists of:



      2 spinners: to display movie name and 1 for movie time
      2 textview to display movie rating and casts
      textview to open calendar



      the spinners should be updated depending on the movie genre selected as well as the textviews for movie rating and cast



      So far i have created the XML for main activity and class to make an arraylist to hold the movie details. I also did intent to go to next page but i am confused on how to display movies in spinner only for selected genre.







      java android arrays xml android-intent






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 15:35









      akm

      33




      33
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          The simplest way would be to pass something to the next activity:



          Intent i = new Intent(context,activity2.class);
          i.putExtra("genre", mGenre);
          startActivity(i);


          Then in activity2 on load you can pull the genre:



          String genre = getintent().getStringExtra("genre");  


          Then you fill the lists based off the genre. You could pass an int as well if you dont feel like dealing with strings.






          share|improve this answer




























            up vote
            0
            down vote













            You should make your movie class Serializable in order to pass it to next Activity.
            There are different ways to achieve that which I have mentioned two in below:




            1. http://www.parcelabler.com/

            2. https://github.com/johncarl81/parceler


            Then you can pass your ArrayList to the second activity.



            FirstActivity



            ArrayList<Movie> myMovieList = new ArrayList<>();
            ...
            Intent intent = new Intent(context, secondActivity.class);
            i.putExtra("my_movie_list", myMovieList);
            startActivity(i);


            SecondActivity



            ArrayList<Movie> myMovieList = getintent().getExtra("my_movie_list");  


            Update (Extracting specific movies from movie list):



                    List<Movie> selectedMovieList = new ArrayList<>();
            for(int i=0 ; i < movieList.size(); i++ ) {
            if(movieList.get(i).getGenre().equals("selected_genre_name")) {
            selectedMovieList.add(movieList.get(i));
            }
            }





            share|improve this answer























            • what does the first link do ?
              – akm
              Nov 9 at 17:11










            • @akm It generates a Serializable data class (model) for you. I personally prefer the second way. Do you have a class or object which refers to movie or genre?
              – Mostafa Aryannejad
              Nov 9 at 17:20










            • i created a class which has the movie details (String genre, String movie_title, Double ratings,String mainCasts, String showTime, Double duration). i add movie details in my second activity
              – akm
              Nov 9 at 17:27










            • @akm If I click one first button in first Activity (For example genre A) and go to second Activity, in the second Activity would I have data of all movies or data of movies with genre A?
              – Mostafa Aryannejad
              Nov 9 at 17:53










            • just the data for genre A
              – akm
              Nov 9 at 19:54











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228761%2fon-button-click-it-updates-the-second-activity-spinner-and-textviews%23new-answer', 'question_page');
            }
            );

            Post as a guest
































            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            The simplest way would be to pass something to the next activity:



            Intent i = new Intent(context,activity2.class);
            i.putExtra("genre", mGenre);
            startActivity(i);


            Then in activity2 on load you can pull the genre:



            String genre = getintent().getStringExtra("genre");  


            Then you fill the lists based off the genre. You could pass an int as well if you dont feel like dealing with strings.






            share|improve this answer

























              up vote
              0
              down vote













              The simplest way would be to pass something to the next activity:



              Intent i = new Intent(context,activity2.class);
              i.putExtra("genre", mGenre);
              startActivity(i);


              Then in activity2 on load you can pull the genre:



              String genre = getintent().getStringExtra("genre");  


              Then you fill the lists based off the genre. You could pass an int as well if you dont feel like dealing with strings.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                The simplest way would be to pass something to the next activity:



                Intent i = new Intent(context,activity2.class);
                i.putExtra("genre", mGenre);
                startActivity(i);


                Then in activity2 on load you can pull the genre:



                String genre = getintent().getStringExtra("genre");  


                Then you fill the lists based off the genre. You could pass an int as well if you dont feel like dealing with strings.






                share|improve this answer












                The simplest way would be to pass something to the next activity:



                Intent i = new Intent(context,activity2.class);
                i.putExtra("genre", mGenre);
                startActivity(i);


                Then in activity2 on load you can pull the genre:



                String genre = getintent().getStringExtra("genre");  


                Then you fill the lists based off the genre. You could pass an int as well if you dont feel like dealing with strings.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 15:44









                Notsileous

                1988




                1988
























                    up vote
                    0
                    down vote













                    You should make your movie class Serializable in order to pass it to next Activity.
                    There are different ways to achieve that which I have mentioned two in below:




                    1. http://www.parcelabler.com/

                    2. https://github.com/johncarl81/parceler


                    Then you can pass your ArrayList to the second activity.



                    FirstActivity



                    ArrayList<Movie> myMovieList = new ArrayList<>();
                    ...
                    Intent intent = new Intent(context, secondActivity.class);
                    i.putExtra("my_movie_list", myMovieList);
                    startActivity(i);


                    SecondActivity



                    ArrayList<Movie> myMovieList = getintent().getExtra("my_movie_list");  


                    Update (Extracting specific movies from movie list):



                            List<Movie> selectedMovieList = new ArrayList<>();
                    for(int i=0 ; i < movieList.size(); i++ ) {
                    if(movieList.get(i).getGenre().equals("selected_genre_name")) {
                    selectedMovieList.add(movieList.get(i));
                    }
                    }





                    share|improve this answer























                    • what does the first link do ?
                      – akm
                      Nov 9 at 17:11










                    • @akm It generates a Serializable data class (model) for you. I personally prefer the second way. Do you have a class or object which refers to movie or genre?
                      – Mostafa Aryannejad
                      Nov 9 at 17:20










                    • i created a class which has the movie details (String genre, String movie_title, Double ratings,String mainCasts, String showTime, Double duration). i add movie details in my second activity
                      – akm
                      Nov 9 at 17:27










                    • @akm If I click one first button in first Activity (For example genre A) and go to second Activity, in the second Activity would I have data of all movies or data of movies with genre A?
                      – Mostafa Aryannejad
                      Nov 9 at 17:53










                    • just the data for genre A
                      – akm
                      Nov 9 at 19:54















                    up vote
                    0
                    down vote













                    You should make your movie class Serializable in order to pass it to next Activity.
                    There are different ways to achieve that which I have mentioned two in below:




                    1. http://www.parcelabler.com/

                    2. https://github.com/johncarl81/parceler


                    Then you can pass your ArrayList to the second activity.



                    FirstActivity



                    ArrayList<Movie> myMovieList = new ArrayList<>();
                    ...
                    Intent intent = new Intent(context, secondActivity.class);
                    i.putExtra("my_movie_list", myMovieList);
                    startActivity(i);


                    SecondActivity



                    ArrayList<Movie> myMovieList = getintent().getExtra("my_movie_list");  


                    Update (Extracting specific movies from movie list):



                            List<Movie> selectedMovieList = new ArrayList<>();
                    for(int i=0 ; i < movieList.size(); i++ ) {
                    if(movieList.get(i).getGenre().equals("selected_genre_name")) {
                    selectedMovieList.add(movieList.get(i));
                    }
                    }





                    share|improve this answer























                    • what does the first link do ?
                      – akm
                      Nov 9 at 17:11










                    • @akm It generates a Serializable data class (model) for you. I personally prefer the second way. Do you have a class or object which refers to movie or genre?
                      – Mostafa Aryannejad
                      Nov 9 at 17:20










                    • i created a class which has the movie details (String genre, String movie_title, Double ratings,String mainCasts, String showTime, Double duration). i add movie details in my second activity
                      – akm
                      Nov 9 at 17:27










                    • @akm If I click one first button in first Activity (For example genre A) and go to second Activity, in the second Activity would I have data of all movies or data of movies with genre A?
                      – Mostafa Aryannejad
                      Nov 9 at 17:53










                    • just the data for genre A
                      – akm
                      Nov 9 at 19:54













                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    You should make your movie class Serializable in order to pass it to next Activity.
                    There are different ways to achieve that which I have mentioned two in below:




                    1. http://www.parcelabler.com/

                    2. https://github.com/johncarl81/parceler


                    Then you can pass your ArrayList to the second activity.



                    FirstActivity



                    ArrayList<Movie> myMovieList = new ArrayList<>();
                    ...
                    Intent intent = new Intent(context, secondActivity.class);
                    i.putExtra("my_movie_list", myMovieList);
                    startActivity(i);


                    SecondActivity



                    ArrayList<Movie> myMovieList = getintent().getExtra("my_movie_list");  


                    Update (Extracting specific movies from movie list):



                            List<Movie> selectedMovieList = new ArrayList<>();
                    for(int i=0 ; i < movieList.size(); i++ ) {
                    if(movieList.get(i).getGenre().equals("selected_genre_name")) {
                    selectedMovieList.add(movieList.get(i));
                    }
                    }





                    share|improve this answer














                    You should make your movie class Serializable in order to pass it to next Activity.
                    There are different ways to achieve that which I have mentioned two in below:




                    1. http://www.parcelabler.com/

                    2. https://github.com/johncarl81/parceler


                    Then you can pass your ArrayList to the second activity.



                    FirstActivity



                    ArrayList<Movie> myMovieList = new ArrayList<>();
                    ...
                    Intent intent = new Intent(context, secondActivity.class);
                    i.putExtra("my_movie_list", myMovieList);
                    startActivity(i);


                    SecondActivity



                    ArrayList<Movie> myMovieList = getintent().getExtra("my_movie_list");  


                    Update (Extracting specific movies from movie list):



                            List<Movie> selectedMovieList = new ArrayList<>();
                    for(int i=0 ; i < movieList.size(); i++ ) {
                    if(movieList.get(i).getGenre().equals("selected_genre_name")) {
                    selectedMovieList.add(movieList.get(i));
                    }
                    }






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 10 at 14:25

























                    answered Nov 9 at 15:48









                    Mostafa Aryannejad

                    248112




                    248112












                    • what does the first link do ?
                      – akm
                      Nov 9 at 17:11










                    • @akm It generates a Serializable data class (model) for you. I personally prefer the second way. Do you have a class or object which refers to movie or genre?
                      – Mostafa Aryannejad
                      Nov 9 at 17:20










                    • i created a class which has the movie details (String genre, String movie_title, Double ratings,String mainCasts, String showTime, Double duration). i add movie details in my second activity
                      – akm
                      Nov 9 at 17:27










                    • @akm If I click one first button in first Activity (For example genre A) and go to second Activity, in the second Activity would I have data of all movies or data of movies with genre A?
                      – Mostafa Aryannejad
                      Nov 9 at 17:53










                    • just the data for genre A
                      – akm
                      Nov 9 at 19:54


















                    • what does the first link do ?
                      – akm
                      Nov 9 at 17:11










                    • @akm It generates a Serializable data class (model) for you. I personally prefer the second way. Do you have a class or object which refers to movie or genre?
                      – Mostafa Aryannejad
                      Nov 9 at 17:20










                    • i created a class which has the movie details (String genre, String movie_title, Double ratings,String mainCasts, String showTime, Double duration). i add movie details in my second activity
                      – akm
                      Nov 9 at 17:27










                    • @akm If I click one first button in first Activity (For example genre A) and go to second Activity, in the second Activity would I have data of all movies or data of movies with genre A?
                      – Mostafa Aryannejad
                      Nov 9 at 17:53










                    • just the data for genre A
                      – akm
                      Nov 9 at 19:54
















                    what does the first link do ?
                    – akm
                    Nov 9 at 17:11




                    what does the first link do ?
                    – akm
                    Nov 9 at 17:11












                    @akm It generates a Serializable data class (model) for you. I personally prefer the second way. Do you have a class or object which refers to movie or genre?
                    – Mostafa Aryannejad
                    Nov 9 at 17:20




                    @akm It generates a Serializable data class (model) for you. I personally prefer the second way. Do you have a class or object which refers to movie or genre?
                    – Mostafa Aryannejad
                    Nov 9 at 17:20












                    i created a class which has the movie details (String genre, String movie_title, Double ratings,String mainCasts, String showTime, Double duration). i add movie details in my second activity
                    – akm
                    Nov 9 at 17:27




                    i created a class which has the movie details (String genre, String movie_title, Double ratings,String mainCasts, String showTime, Double duration). i add movie details in my second activity
                    – akm
                    Nov 9 at 17:27












                    @akm If I click one first button in first Activity (For example genre A) and go to second Activity, in the second Activity would I have data of all movies or data of movies with genre A?
                    – Mostafa Aryannejad
                    Nov 9 at 17:53




                    @akm If I click one first button in first Activity (For example genre A) and go to second Activity, in the second Activity would I have data of all movies or data of movies with genre A?
                    – Mostafa Aryannejad
                    Nov 9 at 17:53












                    just the data for genre A
                    – akm
                    Nov 9 at 19:54




                    just the data for genre A
                    – akm
                    Nov 9 at 19:54


















                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228761%2fon-button-click-it-updates-the-second-activity-spinner-and-textviews%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest




















































































                    Popular posts from this blog

                    List item for chat from Array inside array React Native

                    Thiostrepton

                    Caerphilly