Getting next and previous from ArrayList after data parsed to new activity
Ok, I was complaining about this a few days ago, now I have some code in from following a few tutorials/lessons.
I have a RecyclerView that contains an ArrayList with cards, those have an image, title and description.
I have OnItemClick for those cards, using Parcelable when a card is clicked a second activity opens and shows the full details from the cards - that image, title and description, with a new layout.
I've added a previous and a next button bellow that.
Edit to clarify Struggling with:
I need to have a button in the second activity, the one that opens when clicking on a specific card, and clicking on that button should bring the details from the next card from the first activity. Currently a user would have to go back from the second activity to the recyclerview and click on the next card to see the full details from it
I tried implementing a couple of things I found in older questions here but since they're mostly just code based on somebody else's specific situation I can't seem to edit them in order to get them to work.
I'm adding the link to the repository, it's a bit messy since I'm testing a bunch of things in it, but I'm leaving it for reference: https://github.com/simplydikka/traffic.git
The activities I'm working with currently are those:
Details from list gist
The only walk-around I could find based on my level was to set the click of each card to lead with an if statement to a specific tab from a tabbed activity, but that would mean I will have a very very long list of fragment layouts with different information in them by hand, and that just can't be the answer for something like that. I got that to work but it makes no sense to put that much content by hand when I've already got it to show based on position
EDIT: I got to here:
Intent intent = getIntent();
final ExampleItem exampleItem = intent.getParcelableExtra("Example Item");
position = intent.getExtras().getInt("Position");
final int imageRes = exampleItem.getImageResource();
final String line1 = exampleItem.getTextTitle();
final String line2 = exampleItem.getmTextDescription();
final ImageView imageView = findViewById(R.id.image_activity2);
imageView.setImageResource(imageRes);
final TextView textView1 = findViewById(R.id.text1_activity2);
textView1.setText(line1);
final TextView textView2 = findViewById(R.id.text2_activity2);
textView2.setText(line2);
Button next = (Button) findViewById(R.id.next);
next.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
position = position +1;
imageView.setImageResource(imageRes);
textView1.setText(line1);
textView2.setText(line2);
);
This is in my second activity class, the one that is showing the details and buttons. I got the button to work. I just don't get how to attach a position to the resources. I did the dumbest thing just to see if it would work at all, and when I wrote (imgRes+1) on click the image becomes a black square, so it does affect it finally. I just need to find a way to actually bring the next position. I'm still looking, testing and searching, definitely not sitting around and waiting for somebody to solve it for me, but it would be reeeally cool if anybody passing by could hind me :D
android arraylist onclicklistener parcelable buttonclick
add a comment |
Ok, I was complaining about this a few days ago, now I have some code in from following a few tutorials/lessons.
I have a RecyclerView that contains an ArrayList with cards, those have an image, title and description.
I have OnItemClick for those cards, using Parcelable when a card is clicked a second activity opens and shows the full details from the cards - that image, title and description, with a new layout.
I've added a previous and a next button bellow that.
Edit to clarify Struggling with:
I need to have a button in the second activity, the one that opens when clicking on a specific card, and clicking on that button should bring the details from the next card from the first activity. Currently a user would have to go back from the second activity to the recyclerview and click on the next card to see the full details from it
I tried implementing a couple of things I found in older questions here but since they're mostly just code based on somebody else's specific situation I can't seem to edit them in order to get them to work.
I'm adding the link to the repository, it's a bit messy since I'm testing a bunch of things in it, but I'm leaving it for reference: https://github.com/simplydikka/traffic.git
The activities I'm working with currently are those:
Details from list gist
The only walk-around I could find based on my level was to set the click of each card to lead with an if statement to a specific tab from a tabbed activity, but that would mean I will have a very very long list of fragment layouts with different information in them by hand, and that just can't be the answer for something like that. I got that to work but it makes no sense to put that much content by hand when I've already got it to show based on position
EDIT: I got to here:
Intent intent = getIntent();
final ExampleItem exampleItem = intent.getParcelableExtra("Example Item");
position = intent.getExtras().getInt("Position");
final int imageRes = exampleItem.getImageResource();
final String line1 = exampleItem.getTextTitle();
final String line2 = exampleItem.getmTextDescription();
final ImageView imageView = findViewById(R.id.image_activity2);
imageView.setImageResource(imageRes);
final TextView textView1 = findViewById(R.id.text1_activity2);
textView1.setText(line1);
final TextView textView2 = findViewById(R.id.text2_activity2);
textView2.setText(line2);
Button next = (Button) findViewById(R.id.next);
next.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
position = position +1;
imageView.setImageResource(imageRes);
textView1.setText(line1);
textView2.setText(line2);
);
This is in my second activity class, the one that is showing the details and buttons. I got the button to work. I just don't get how to attach a position to the resources. I did the dumbest thing just to see if it would work at all, and when I wrote (imgRes+1) on click the image becomes a black square, so it does affect it finally. I just need to find a way to actually bring the next position. I'm still looking, testing and searching, definitely not sitting around and waiting for somebody to solve it for me, but it would be reeeally cool if anybody passing by could hind me :D
android arraylist onclicklistener parcelable buttonclick
could you please update the question to specify what consisely you're looking to do? It sounds like pass data from one caller to next so that it remains between activities. I know you can set a value to store the array against a variable that persists between activities.
– Frankenmint
Nov 10 '18 at 12:39
1
@Frankenmint My English and stuff I guess... I'll try to update it. Basically I have a list of cards in a recyclerview with information in them, a click on those already opens a new activity and populates it using parcelable with in a different layout with the information from the card clicked. All I need to do is add a button to that second activity that pulls the next card from the recyclerview, instead of having to go back to the cards and click the next card to open the full details screen
– simplydikka
Nov 10 '18 at 12:43
add a comment |
Ok, I was complaining about this a few days ago, now I have some code in from following a few tutorials/lessons.
I have a RecyclerView that contains an ArrayList with cards, those have an image, title and description.
I have OnItemClick for those cards, using Parcelable when a card is clicked a second activity opens and shows the full details from the cards - that image, title and description, with a new layout.
I've added a previous and a next button bellow that.
Edit to clarify Struggling with:
I need to have a button in the second activity, the one that opens when clicking on a specific card, and clicking on that button should bring the details from the next card from the first activity. Currently a user would have to go back from the second activity to the recyclerview and click on the next card to see the full details from it
I tried implementing a couple of things I found in older questions here but since they're mostly just code based on somebody else's specific situation I can't seem to edit them in order to get them to work.
I'm adding the link to the repository, it's a bit messy since I'm testing a bunch of things in it, but I'm leaving it for reference: https://github.com/simplydikka/traffic.git
The activities I'm working with currently are those:
Details from list gist
The only walk-around I could find based on my level was to set the click of each card to lead with an if statement to a specific tab from a tabbed activity, but that would mean I will have a very very long list of fragment layouts with different information in them by hand, and that just can't be the answer for something like that. I got that to work but it makes no sense to put that much content by hand when I've already got it to show based on position
EDIT: I got to here:
Intent intent = getIntent();
final ExampleItem exampleItem = intent.getParcelableExtra("Example Item");
position = intent.getExtras().getInt("Position");
final int imageRes = exampleItem.getImageResource();
final String line1 = exampleItem.getTextTitle();
final String line2 = exampleItem.getmTextDescription();
final ImageView imageView = findViewById(R.id.image_activity2);
imageView.setImageResource(imageRes);
final TextView textView1 = findViewById(R.id.text1_activity2);
textView1.setText(line1);
final TextView textView2 = findViewById(R.id.text2_activity2);
textView2.setText(line2);
Button next = (Button) findViewById(R.id.next);
next.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
position = position +1;
imageView.setImageResource(imageRes);
textView1.setText(line1);
textView2.setText(line2);
);
This is in my second activity class, the one that is showing the details and buttons. I got the button to work. I just don't get how to attach a position to the resources. I did the dumbest thing just to see if it would work at all, and when I wrote (imgRes+1) on click the image becomes a black square, so it does affect it finally. I just need to find a way to actually bring the next position. I'm still looking, testing and searching, definitely not sitting around and waiting for somebody to solve it for me, but it would be reeeally cool if anybody passing by could hind me :D
android arraylist onclicklistener parcelable buttonclick
Ok, I was complaining about this a few days ago, now I have some code in from following a few tutorials/lessons.
I have a RecyclerView that contains an ArrayList with cards, those have an image, title and description.
I have OnItemClick for those cards, using Parcelable when a card is clicked a second activity opens and shows the full details from the cards - that image, title and description, with a new layout.
I've added a previous and a next button bellow that.
Edit to clarify Struggling with:
I need to have a button in the second activity, the one that opens when clicking on a specific card, and clicking on that button should bring the details from the next card from the first activity. Currently a user would have to go back from the second activity to the recyclerview and click on the next card to see the full details from it
I tried implementing a couple of things I found in older questions here but since they're mostly just code based on somebody else's specific situation I can't seem to edit them in order to get them to work.
I'm adding the link to the repository, it's a bit messy since I'm testing a bunch of things in it, but I'm leaving it for reference: https://github.com/simplydikka/traffic.git
The activities I'm working with currently are those:
Details from list gist
The only walk-around I could find based on my level was to set the click of each card to lead with an if statement to a specific tab from a tabbed activity, but that would mean I will have a very very long list of fragment layouts with different information in them by hand, and that just can't be the answer for something like that. I got that to work but it makes no sense to put that much content by hand when I've already got it to show based on position
EDIT: I got to here:
Intent intent = getIntent();
final ExampleItem exampleItem = intent.getParcelableExtra("Example Item");
position = intent.getExtras().getInt("Position");
final int imageRes = exampleItem.getImageResource();
final String line1 = exampleItem.getTextTitle();
final String line2 = exampleItem.getmTextDescription();
final ImageView imageView = findViewById(R.id.image_activity2);
imageView.setImageResource(imageRes);
final TextView textView1 = findViewById(R.id.text1_activity2);
textView1.setText(line1);
final TextView textView2 = findViewById(R.id.text2_activity2);
textView2.setText(line2);
Button next = (Button) findViewById(R.id.next);
next.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
position = position +1;
imageView.setImageResource(imageRes);
textView1.setText(line1);
textView2.setText(line2);
);
This is in my second activity class, the one that is showing the details and buttons. I got the button to work. I just don't get how to attach a position to the resources. I did the dumbest thing just to see if it would work at all, and when I wrote (imgRes+1) on click the image becomes a black square, so it does affect it finally. I just need to find a way to actually bring the next position. I'm still looking, testing and searching, definitely not sitting around and waiting for somebody to solve it for me, but it would be reeeally cool if anybody passing by could hind me :D
android arraylist onclicklistener parcelable buttonclick
android arraylist onclicklistener parcelable buttonclick
edited Nov 10 '18 at 13:36
simplydikka
asked Nov 10 '18 at 12:35
simplydikkasimplydikka
304
304
could you please update the question to specify what consisely you're looking to do? It sounds like pass data from one caller to next so that it remains between activities. I know you can set a value to store the array against a variable that persists between activities.
– Frankenmint
Nov 10 '18 at 12:39
1
@Frankenmint My English and stuff I guess... I'll try to update it. Basically I have a list of cards in a recyclerview with information in them, a click on those already opens a new activity and populates it using parcelable with in a different layout with the information from the card clicked. All I need to do is add a button to that second activity that pulls the next card from the recyclerview, instead of having to go back to the cards and click the next card to open the full details screen
– simplydikka
Nov 10 '18 at 12:43
add a comment |
could you please update the question to specify what consisely you're looking to do? It sounds like pass data from one caller to next so that it remains between activities. I know you can set a value to store the array against a variable that persists between activities.
– Frankenmint
Nov 10 '18 at 12:39
1
@Frankenmint My English and stuff I guess... I'll try to update it. Basically I have a list of cards in a recyclerview with information in them, a click on those already opens a new activity and populates it using parcelable with in a different layout with the information from the card clicked. All I need to do is add a button to that second activity that pulls the next card from the recyclerview, instead of having to go back to the cards and click the next card to open the full details screen
– simplydikka
Nov 10 '18 at 12:43
could you please update the question to specify what consisely you're looking to do? It sounds like pass data from one caller to next so that it remains between activities. I know you can set a value to store the array against a variable that persists between activities.
– Frankenmint
Nov 10 '18 at 12:39
could you please update the question to specify what consisely you're looking to do? It sounds like pass data from one caller to next so that it remains between activities. I know you can set a value to store the array against a variable that persists between activities.
– Frankenmint
Nov 10 '18 at 12:39
1
1
@Frankenmint My English and stuff I guess... I'll try to update it. Basically I have a list of cards in a recyclerview with information in them, a click on those already opens a new activity and populates it using parcelable with in a different layout with the information from the card clicked. All I need to do is add a button to that second activity that pulls the next card from the recyclerview, instead of having to go back to the cards and click the next card to open the full details screen
– simplydikka
Nov 10 '18 at 12:43
@Frankenmint My English and stuff I guess... I'll try to update it. Basically I have a list of cards in a recyclerview with information in them, a click on those already opens a new activity and populates it using parcelable with in a different layout with the information from the card clicked. All I need to do is add a button to that second activity that pulls the next card from the recyclerview, instead of having to go back to the cards and click the next card to open the full details screen
– simplydikka
Nov 10 '18 at 12:43
add a comment |
0
active
oldest
votes
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',
autoActivateHeartbeat: false,
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
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239007%2fgetting-next-and-previous-from-arraylist-after-data-parsed-to-new-activity%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239007%2fgetting-next-and-previous-from-arraylist-after-data-parsed-to-new-activity%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
could you please update the question to specify what consisely you're looking to do? It sounds like pass data from one caller to next so that it remains between activities. I know you can set a value to store the array against a variable that persists between activities.
– Frankenmint
Nov 10 '18 at 12:39
1
@Frankenmint My English and stuff I guess... I'll try to update it. Basically I have a list of cards in a recyclerview with information in them, a click on those already opens a new activity and populates it using parcelable with in a different layout with the information from the card clicked. All I need to do is add a button to that second activity that pulls the next card from the recyclerview, instead of having to go back to the cards and click the next card to open the full details screen
– simplydikka
Nov 10 '18 at 12:43