Good day, I know that this question has been already been asked. But as searched none of their solutions works for me regarding with this topic.
I compiled the gradle - compile 'de.hdodenhof:circleimageview:1.3.0'
. I created header.xml
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
app:border_color="#FF000000"
android:layout_marginLeft="24dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_margin="@dimen/activity_vertical_margin"
android:layout_marginStart="@dimen/activity_vertical_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:src="@drawable/avatar"
android:foreground="?attr/selectableItemBackground"
android:onClick="onClick"
android:clickable="true" />
For my navigationView
.
<!--NAVIGATION DRAWER-->
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/header"
app:menu="@menu/navigation_drawer"
app:itemIconTint="@color/colorTextNavigationView" />
In my java file activity_main.java
I tried the onClickListener yet it will stop my program - nullPointerException (cannot mapped my circleImageView findViewById).and even setNavigationItemSelectedListener will not launched the the intents if I clicked the circle image.
mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
menuItem.setChecked(true);
mDrawerLayout.closeDrawers();
int id = menuItem.getItemId();
switch (id){ // INTENTS HERE}
}
Is there a way to make this clickable?