Git Product home page Git Product logo

Comments (6)

rajsuvariya avatar rajsuvariya commented on August 20, 2024 1

You can set on click in child view holder class
itemview.setonclicklistner();

from expandable-recycler-view.

traifdevelopment avatar traifdevelopment commented on August 20, 2024

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.

rajsuvariya avatar rajsuvariya commented on August 20, 2024

Can you share your code?

from expandable-recycler-view.

traifdevelopment avatar traifdevelopment commented on August 20, 2024

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.

rajsuvariya avatar rajsuvariya commented on August 20, 2024

@mandybess Please have a look at it.

from expandable-recycler-view.

traifdevelopment avatar traifdevelopment commented on August 20, 2024

Tell me when you can. Im with this library in my job...
Thanks.

from expandable-recycler-view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.