Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Changing background color of selected item in recyclerview

public void onBindViewHolder(final ViewHolder holder, final int position) {
        holder.tv1.setText(android_versionnames[position]);

        holder.row_linearlayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                row_index=position;
                notifyDataSetChanged();
            }
        });
        if(row_index==position){
            holder.row_linearlayout.setBackgroundColor(Color.parseColor("#567845"));
            holder.tv1.setTextColor(Color.parseColor("#ffffff"));
        }
        else
        {
            holder.row_linearlayout.setBackgroundColor(Color.parseColor("#ffffff"));
            holder.tv1.setTextColor(Color.parseColor("#000000"));
        }

    }
Comment

PREVIOUS NEXT
Code Example
Java :: java read integer from text file into array scanner 
Java :: how to initialize an empty array in java 
Java :: how to get current time and date in android 
Java :: How to get the nth Fibonacci number code in Java using recursion 
Java :: array of number arrays java 
Java :: first and last digit of a number in java 
Java :: java split int 
Java :: java clear string buffer 
Java :: java lb to kg 
Java :: spring boot get request body 
Java :: java leap years 
Java :: class declaration in java 
Java :: java variable declaration 
Java :: java http response code 
Java :: System.out.printf("%"+(n)+"s ") 
Java :: integer to binary java 
Java :: java how to create an array 
Java :: print 1 to 10 using thread in java 
Java :: even and odd java & 
Java :: équivalent setTimeInterval java 
Java :: how to replace an element in array in java 
Java :: print a list java 
Java :: java multithreading 
Java :: unchecked exception in java 
Java :: java read file from command line argument 
Java :: java ints to color int 
Java :: interface extending interface in java 
Java :: method parameters in java 
Java :: Android Number Picker format JAVA 
Java :: declaring variables views in java android 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =