LevisLuong / SubLabelView_Android

Sub label view on the top for tips or notification text view.
0 stars 1 forks source link

RecyclerView? #1

Open khaledkhj opened 8 years ago

khaledkhj commented 8 years ago

Thanks for this great lib and I am trying to using it in recyclerview but it randomly changes labels' places as you scroll up and down. So could you please help in this?

Thanks in advanced.

LevisLuong commented 8 years ago

@khaledkhj You can use Recyclerview with ViewHolder to handle labelview.

khaledkhj commented 8 years ago

I am still trying, but didn't work. this is how I implemented it

LabelView label = new LabelView(context); label.setText(value); label.setBackgroundColor(Color.parseColor(color)); label.setTargetView(row, 15, LabelView.Gravity.RIGHT_TOP, 20);

the above code is being used in ViewHolder class.

Any idea how should I use it !!

LevisLuong commented 8 years ago

It have noted in tutorial:

LabelView in BaseAdpter if you using LabelView in BaseAdpter and reuse of convertView, you have to generate label ID manual. eg:

public View getItemView(int position, View convertView, ViewHolder holder) {

......

// you have to generate label ID manual
LabelView label = holder.getView(12345);
if (label == null) {
    label = new LabelView(this);
    label.setId(12345);
    label.setBackgroundColor(0xffE91E63);
    label.setTargetViewInBaseAdapter(imageView, 138, 10, LabelView.Gravity.LEFT_TOP);
}
label.setText(your data);
return convertView;

}

LevisLuong commented 8 years ago

You can see example use this lib with recycler view here: http://pastebin.com/6dQmiHnk