I'm creating an andorid app to capture a users mood. I have currently set up a list view to display the available mood options to screen.

I am now trying to implement a function which allows the user to select multiple items in the list view by touching them onscreen. When the user selects the item it should be highlighted in some way so it is obvious it has been selected i.e. the background colour changes. Currently I have this set up where I can select one item and it changes to red. However I want the user to be able to select multiple items and their background colours should all change to red before the user selects the next button to move on.

    protected void onCreate(Bundle savedInstanceState) {

    listView = findViewById(R.id.distortedListViewWorkout);
    MyAdapter adapter = new MyAdapter(this, mTitle, images);
    button = findViewById(R.id.nextBtn);
    button.setOnClickListener(new View.OnClickListener() {

         * @param v
        public void onClick(View v) {

            Intent intent = new Intent(WorkoutDistortedThoughtsActivity.this, WorkoutChallengeActivity.class);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            if (position >=0 ) {


     class MyAdapter extends ArrayAdapter<String> {

        Context context;
        String rTitle[];
        int rImages[];

        MyAdapter (Context c, String title[], int images[]){
            super(c, R.layout.row, R.id.titleEtWorkout, title);
            this.context = c;
            this.rTitle = title;
            this.rImages = images;


Related posts

Recent Viewed