android - Click Text on Recyclerview to expand -
i have recyclerview works instagram ui. want set onclick listener text below image expands when clicked , collapse when clicked again instagram app. below how looks like.
so when "lorem ipsum" text clicked, should expand , show rest of text. when clicked again, should collapse.
this how wrote textview in cardview.xml
<textview android:id="@+id/mcarddescription" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="4dp" android:layout_marginright="10dp" android:layout_marginstart="4dp" android:maxlines="2" android:text="lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation" />
really need help.thanks in advance.
inside onbindviewholder can set click listener particular text view want expand or collapse. in below code rh row holder object, expandable boolean value check if text expanded or not. let me know if have issues.
onbindviewholde(....){ rh.readmoretxt.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { if (!rh.expandable) { rh.expandable = true; rh.readmoretxt.settext("show less"); } else { rh.expandable = false; rh.readmoretxt.settext("show more"); } } }); }
Comments
Post a Comment