Going to another activity and moving back but keeping the content that was already there

AtanasAngelovAtanasAngelov Member ✭✭✭

Currently i am trying to find a way which when you want to change the quantity of the item, my question is, can i go to another activity which will have a text view where you can insert the quantity and therefore changing the actual quantity of the current selected item OR can i open another dialog from the one that was open which will have a way to insert the new quantity or something else that will help me

Best Answers

  • AtanasAngelovAtanasAngelov ✭✭✭
    Accepted Answer

    Thanks to StartActivityForResult, i was able to solve this issue, SO since i am using a recyclerView, what i have done is, i made a brand new activity with an editor and a text view, from the adapter that controls the recyclerview, i have started StartActivityForResult that will go to that activity it will wait until the user hits the button which will go back to the activity where the recyclerview is, put the quantity or the value in a variable and from there i was able to update it and it works perfectly fine

Answers

  • AtanasAngelovAtanasAngelov Member ✭✭✭

    That might work, as i am using an adapter, and i have done the part where i can delete an item and it will automatically change a value which stores the total amount of money for the whole order, now i want to do the same thing, but this time to change the quantity of the item, they way that the old application for the project in Windows phones was going to a different page, you insert the new quantity and it auto updates, i would like to do something like that

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Can you give me a gif result for your need? or some pictures? based on your description, I do not know what you specific need.

  • AtanasAngelovAtanasAngelov Member ✭✭✭

    So in my project, i have a recyclerview which stores the item's name, quantity, how much it costs for one and total if there are more than one selected like 2,

    this is an example of how it works, when you long click on an item, it will show up an alert dialog with two options, one of them is to remove the current selected item while the other is change the quantity of the item, i have done the removing bit, but i still dont know how to tackle the change quantity option which should change the selected quantity from like 1 to 3 and therefore changing the total for that row from the old to the new one. And those were the ways that i wanted to do it, and i wanted to see if i can actually do it.

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    @AtanasAngelov
    Please refer to this link, remove to "Update single item" title, when you change the data in the recycleview, you just call this methodadapter.notifyItemChanged(updateIndex);, recycleView will update it.

    https://medium.com/@suragch/updating-data-in-an-android-recyclerview-842e56adbfd8

  • AtanasAngelovAtanasAngelov Member ✭✭✭

    i am aware of that actually, and i have been using it, i do have some ideas of how i want to do it, once i am done i will let you know if it worked

  • LeonLuLeonLu Member, Xamarin Team Xamurai
    edited August 8

    @AtanasAngelov
    Ok, If the reply is helpful, please mark it as an answer, it will help others who have similar issue.

  • AtanasAngelovAtanasAngelov Member ✭✭✭

    I am currently working on finding a way where the user can go to an activity, finish what they are doing, get the result and come back, and i do believe i can achieve that through StartActivityForResult(), do i keep the same layout for the activity too, or general do i need to add anything extra for this to work.

  • AtanasAngelovAtanasAngelov Member ✭✭✭
    Accepted Answer

    Thanks to StartActivityForResult, i was able to solve this issue, SO since i am using a recyclerView, what i have done is, i made a brand new activity with an editor and a text view, from the adapter that controls the recyclerview, i have started StartActivityForResult that will go to that activity it will wait until the user hits the button which will go back to the activity where the recyclerview is, put the quantity or the value in a variable and from there i was able to update it and it works perfectly fine

Sign In or Register to comment.