Skip to content

Instantly share code, notes, and snippets.

public class ViewHolder extends RecyclerView.ViewHolder {
TextView textView;
public ViewHolder(View itemView) {
super(itemView);
// Look up all of your views here, findViewById can be somewhat costl
// so you don't want to do it every time the view is recycled
textView = ((ViewGroup)itemView).findViewById(R.id.my_text_view);
}
public void bind(Model model) {
if (model.id % 2 == 0) {
myLayout.setBackgroundResource(R.drawable.background_01); //works
textView.setTextColor(Color.BLACK);
} else {
myLayout.setBackgroundResource(R.drawable.background_02); //works
textView.setTextColor(Color.RED); // it's changing the color of the ones that are not "potato"
}
textView.setText(model.myText); //works
}
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import com.warmice.android.pathfinderrulebooks.ui.listener.TransactionListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by gabriel on 7/19/15.
@konk3r
konk3r / game.rb
Created September 18, 2016 21:36
class Game
def self.run()
<put code here>
end
end
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import android.support.v7.recyclerview.extensions.ListAdapter
import android.support.v7.util.DiffUtil
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
class ${NAME} : ListAdapter<${Model_Class}, ${NAME}.ItemViewHolder>(DiffCallback()) {