mgolokhov / dodroid

May the knowledge be with you!
MIT License
20 stars 12 forks source link

Not able to implement on clickListener in TopicsActivity. #52

Closed vixir closed 8 years ago

vixir commented 8 years ago

I wanted to set checkbox as clicked on the relativelayout view click. The OnClickListener in TopicViewHolder is not working.

itemView,setOnClickListener(this)

`public TopicViewHolder(View itemView) { super(itemView); topic = (TextView)itemView.findViewById(R.id.topic_name); checkbox = (CheckBox) itemView.findViewById(R.id.checkbox_tag); itemView.setOnClickListener(this); }

@Override public void onClick(View v) { Toast.makeText(v.getContext(), topic.getText(), Toast.LENGTH_SHORT); }`

mgolokhov commented 8 years ago

This functionality is already there, just call show()

Toast.makeText(v.getContext(), topic.getText(), Toast.LENGTH_SHORT).show();

If you want to observe specifically checkbox, you have to set listener

checkbox.setOnClickListener(this);

then don't forget to compare view ids in onClick handler.