Comments (6)
You can set on click in child view holder class
itemview.setonclicklistner();
from expandable-recycler-view.
That doesn't work for me. In view i cant do setOnclick.
Well, I can, but doesn't respond. When I put in TextView, work perfectly.
Can someone help me?
from expandable-recycler-view.
Can you share your code?
from expandable-recycler-view.
Of course.
XML:
`
<android.support.v7.widget.CardView
android:layout_width="match_parent"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardCornerRadius="0dp"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:id="@+id/line"
android:clickable="true"
android:layout_height="wrap_content">
<LinearLayout
android:background="#ffffff"
android:orientation="horizontal"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--What you want to show in SurfaceView-->
<ImageView
android:id="@+id/image"
android:layout_width="@dimen/perfil_image_size"
android:layout_height="@dimen/perfil_image_size"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_gravity="center_vertical" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_marginBottom="15dp"
android:clickable="true"
android:layout_height="wrap_content">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="name"
android:maxEms="12"
android:singleLine="false"
android:layout_marginLeft="15dp"
android:textColor="@android:color/black"
android:textSize="16sp"
android:layout_marginTop="15dp" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="time"
android:layout_marginLeft="15dp"
android:textColor="@android:color/black"
android:textSize="14sp"
android:layout_marginTop="5dp" />
</LinearLayout>
<ImageView
android:text="Button"
android:layout_gravity="right"
android:src="@drawable/ic_keyboard_arrow_right_black_48px"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/imageView" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="@android:color/darker_gray"/>
</android.support.v7.widget.CardView>
`
ADAPTER:
`public class ExpandableAdapter extends ExpandableRecyclerViewAdapter<GroupViewHolder, CViewHolder> {
Context c;
LayoutInflater mInflater;
public ExpandableAdapter(List<? extends ExpandableGroup> groups, Context) {
super(groups);
this.c = c;
mInflater = LayoutInflater.from(c);
}
@Override
public GroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.layout_group, parent, false);
return new GroupViewHolder(view);
}
@Override
public ChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
View view = mInflater.inflate(R.layout.layout_child, parent, false);
return new CViewHolder(view, c);
}
@Override
public void onBindChildViewHolder(CViewHolderholder, int flatPosition, ExpandableGroup group, int childIndex) {
final Person objeto = ((Person) group.getItems().get(childIndex));
holder.onBind(objeto, group.getTitle());
@Override
public void onBindGroupViewHolder(GroupViewHolder holder, int flatPosition, ExpandableGroup group) {
holder.setGenreTitle(group);
}
`
ChildViewHolder:
`
public class CViewHolder extends ChildViewHolder {
public TextView name, time, cantidad;
public ImageView image;
Context context;
View itemView;
public CViewHolder(final View itemView, final Context context) {
super(itemView);
this.itemView = itemView;
this.itemView.setClickable(true);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
System.out.println("HAHA");
}
});
this.context = context;
name = (TextView) itemView.findViewById(R.id.name);
time = (TextView)itemView.findViewById(R.id.time);
image = (ImageView) itemView.findViewById(R.id.image);
image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
System.out.println("HAHA");
}
});
}
public void onBind(final Person persona, final String horarioComida) {
name.setText(persona.getname());
time.setText(persona.getTime());
Glide.with(context).load(persona.getimage()).into(image);
}
}`
When I press in "image.setOnclick", works perfectly, when i press in view, doesn't work...
from expandable-recycler-view.
@mandybess Please have a look at it.
from expandable-recycler-view.
Tell me when you can. Im with this library in my job...
Thanks.
from expandable-recycler-view.
Related Issues (20)
- How to add delete on swipe to childviewitem.I am not able to get the position of child and parent item in my Fragment.Please help
- when i click on artist itemview and back again recycler view is gone HOT 1
- Add data from api
- Is it possible to put single and multiple check items in one recyclerview?
- Display the same background for Childs
- MultiTypeExpandableRecyclerViewAdapter automatically use animation in OnStart method
- How to use it with Paging HOT 1
- Tried to use preview panel provider (JavaFX WebView), but it is unavailable. Reverting to default
- There is a `toggleGroup` function which will expand a group if it is collapsed
- collapse will be called automaticly when start activity. HOT 1
- Duplicate child when expanding parents multiple times (latest release) HOT 1
- why child's default interval is big and how to setting?
- Strange Behavior on Dynamic Group Header Size
- EXPAND_STATE_MAP is private
- Migrate away from jCenter HOT 5
- Element Sorting
- When app not used for a while, expandablerecyclerview menus are empty HOT 1
- Expand and collapse smoothly HOT 1
- Allow me push access...I have updated the project to latest environment
- Error dowloading library HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expandable-recycler-view.