-1

I made SQL database with all functions. In my activity with RecyclerView (Recycler is listing all items in SQL database) I made a function to check (setBackgroundColor) selected item after I enter specific value for that item.

To be more clear:

if(foodList.get(position).getGram() > 0) {
        holder.row_linearlayout.setBackgroundColor(ContextCompat.getColor(context, R.color.colorAccent));
    }else{
        holder.row_linearlayout.setBackgroundColor(ContextCompat.getColor(context, R.color.white));
    }

So, if I enter specific value (with EditText) that item will change background color.

The problem is that somehow in second activity I need to pass ONLY selected items (items with changed background color) in RecyclerView. And I dont have logic or idea how to do that. Any advice would be helpfull.

Let me know if you need some more of my code to better understand my question.

odin_allfather
  • 29
  • 2
  • 11

1 Answers1

0

When you want to start a new activity you can create an Intent. The Intent object will allow you to call .putExtra() where you can inset a (key, value) pair - the key being the unique identifier of the value so that the activity you are calling can get a value based on the key. In your case, the value will be the details of the coloured list items.

Better said than me: https://developer.android.com/reference/android/content/Intent.html

  • Actually the setBackgroundColor is just for the user so he can see the difference betwen items with extra values and with no extra values. What I need to pass is row in my table. So for the value I just need to put name of the row ? Sounds to simple to be true. – odin_allfather Aug 03 '17 at 15:30