Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the row clickable to move another activity with Ripple effect #9

Open
sivailango opened this issue Jun 17, 2015 · 7 comments
Open

Comments

@sivailango
Copy link

Hi @slidenerd,

First of all thanks for you Material Design video tutorial.

I have two issues.
First one is, when i try click on the link on RecyclerView, it moves to sub activity only when click on the icon of menu list. So i added click listener for title too. Now it works, but ripple effect is only working when i click other than icon and title. I want to implement the click event anywhere on the item with ripple effect and it should take me to sub activity.

class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

    TextView title;
    ImageView item;

    public MyViewHolder(View itemView) {
        super(itemView);
        title = (TextView) itemView.findViewById(R.id.listMessage);
        item = (ImageView) itemView.findViewById(R.id.listItem);
        item.setOnClickListener(this);
        title.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        //Toast.makeText(context, "Item clicked at " + getPosition(), Toast.LENGTH_SHORT).show();
        //delete(getPosition());
        context.startActivity(new Intent(context, SubActivity.class));
    }
}    

Also i when back to MainActivity from SubActivity the Navigation is still in open status.

How do i solve it?

@ghost
Copy link

ghost commented Jun 19, 2015

try to set on your item_drawer.xml the background this way = android :
background = " ? android : attr / selectableItemBackground "

@sivailango
Copy link
Author

<?xml version="1.0" encoding="utf-8"?>

<ImageView
    android:id="@+id/listItem"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_centerVertical="true"
    android:src="@drawable/ic_account_circle_grey_800_18dp" />

<TextView
    android:id="@+id/listMessage"
    android:padding="8dp"
    android:layout_marginLeft="72dp"
    android:layout_centerVertical="true"
    android:layout_width="wrap_content"
    android:layout_gravity="center_vertical"
    android:layout_height="wrap_content"
    android:text="Profile" />

This is my item_drawer.xml. But it didn't work.

@ghost
Copy link

ghost commented Jun 19, 2015

create a RelativeLayout and set android:background="?android:attr/selectableItemBackground" and it put the TextView and ImageView inside .

@sivailango
Copy link
Author

Already that is inside the RelativeLayout.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackground"
android:clickable="true">

<ImageView
    android:id="@+id/listItem"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_centerVertical="true"
    android:src="@drawable/ic_account_circle_grey_800_18dp" />

<TextView
    android:id="@+id/listMessage"
    android:padding="8dp"
    android:layout_marginLeft="72dp"
    android:layout_centerVertical="true"
    android:layout_width="wrap_content"
    android:layout_gravity="center_vertical"
    android:layout_height="wrap_content"
    android:text="Profile" />

</RelativeLayout>

@ghost
Copy link

ghost commented Jun 20, 2015

bus this RelativeLayout is the main, create other, also I went through this
problem

2015-06-19 23:48 GMT-03:00 Sivailango [email protected]:

Already that is inside the RelativeLayout.


Reply to this email directly or view it on GitHub
#9 (comment)
.

"As pessoas não sabem oque querem até você mostrar a elas"

Steve
Jobs

Rafael Almeida Barbosa
Graduando em Sistemas de Informação - UFBA

@ghost
Copy link

ghost commented Jun 20, 2015

 <RelativeLayout 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal" android:layout_width="match_parent"
      android:layout_height="48dp"
      android:clickable="true">

 <RelativeLayout
       android:layout_width="match_parent"
        android:layout_height="wrap_content"
       android:background="?android:attr/selectableItemBackground"/>

  <ImageView android:id="@+id/listItem" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp" android:layout_centerVertical="true"
        android:src="@drawable/ic_account_circle_grey_800_18dp" />

 <TextView
       android:id="@+id/listMessage" android:padding="8dp"
       android:layout_marginLeft="72dp" android:layout_centerVertical="true"
       android:layout_width="wrap_content"
       android:layout_gravity="center_vertical"
       android:layout_height="wrap_content" android:text="Profile" />

 </RelativeLayout>

 </RelativeLayout>

2015-06-20 9:43 GMT-03:00 Rafael Almeida Barbosa <[email protected]

:

bus this RelativeLayout is the main, create other, also I went through
this problem

2015-06-19 23:48 GMT-03:00 Sivailango [email protected]:

Already that is inside the RelativeLayout.


Reply to this email directly or view it on GitHub
#9 (comment)
.

"As pessoas não sabem oque querem até você mostrar a elas"
Steve
Jobs

Rafael Almeida Barbosa
Graduando em Sistemas de Informação - UFBA

"As pessoas não sabem oque querem até você mostrar a elas"

Steve
Jobs

Rafael Almeida Barbosa
Graduando em Sistemas de Informação - UFBA

@amanbajpaigate6
Copy link

get position code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants