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.
java
add a comment |
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.
java
add a comment |
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.
java
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
java
asked Nov 9 at 15:35
akm
33
33
add a comment |
add a comment |
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.
add a comment |
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:
- http://www.parcelabler.com/
- 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));
}
}
what does the first link do ?
– akm
Nov 9 at 17:11
@akm It generates aSerializabledata 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
|
show 10 more comments
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 9 at 15:44
Notsileous
1988
1988
add a comment |
add a comment |
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:
- http://www.parcelabler.com/
- 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));
}
}
what does the first link do ?
– akm
Nov 9 at 17:11
@akm It generates aSerializabledata 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
|
show 10 more comments
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:
- http://www.parcelabler.com/
- 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));
}
}
what does the first link do ?
– akm
Nov 9 at 17:11
@akm It generates aSerializabledata 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
|
show 10 more comments
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:
- http://www.parcelabler.com/
- 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));
}
}
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:
- http://www.parcelabler.com/
- 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));
}
}
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 aSerializabledata 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
|
show 10 more comments
what does the first link do ?
– akm
Nov 9 at 17:11
@akm It generates aSerializabledata 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
|
show 10 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password