initUI() in Fragment is giving error in Image view - android

In Fragment, I made initUI() and initializes image view, but getting error.Not able why it is getting an error. I'm providing Fragment's initUI() and XML files.
Error:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
at novumlogic.payment.home.CateFragment.initUI(CateFragment.java:95)
at novumlogic.payment.home.CateFragment.onCreate(CateFragment.java:61)
Fragment
private void initUI() {
//#SuppressLint("ResourceType") AppCompatTextView tvDay = ((AppCompatTextView) rootView.findViewById(R.id.imgSendMoney,16.0F));
//AppCompatTextView tvDay1 = (AppCompatTextView) rootView.findViewById(R.id.imgReceiveMoney);
ViewCompat.setElevation((ImageView) rootView.findViewById(R.id.imgSendMoney), 16.0F);
ViewCompat.setElevation((ImageView)rootView.findViewById(R.id.imgReceiveMoney), 16.0F);
/*((AppCompatImageView)root.findViewById(R.id.imgNotification)).setOnClickListener((View.OnClickListener) new View.OnClickListener() {
public final void onClick(View it) {
Toast.makeText((Context)HomeFragment.this, (CharSequence)"Notification List", 0).show();
}
});*/
((CardView)rootView.findViewById(R.id.cardSendMoney)).setOnClickListener((View.OnClickListener)(new View.OnClickListener() {
public final void onClick(View it) {
Intent k = new Intent(getContext(), SendMoneyActivity.class);
startActivity(k);
//HomeFragment.this.startActivity(new Intent((Context)HomeFragment.this.getActivity(), SendMoneyActivity.class));
}
}));
CardView card_view = (CardView) rootView.findViewById(R.id.cardReceiveMoney);
card_view.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// do whatever you want to do on click (to launch any fragment or activity you need to put intent here.)
Intent k = new Intent(getContext(), ReceiveMoneyActivity.class);
startActivity(k);
}
});
((RecyclerView)rootView.findViewById(R.id.recyclerBankAccounts)).setItemViewCacheSize(0);
((RecyclerView)rootView.findViewById(R.id.recyclerBankAccounts)).setHasFixedSize(true);
RecyclerView var10000 = (RecyclerView)rootView.findViewById(R.id.recyclerBankAccounts);
Intrinsics.checkExpressionValueIsNotNull(var10000, "root.recyclerBankAccounts");
var10000.setLayoutManager((RecyclerView.LayoutManager)(new LinearLayoutManager((Context)this.getActivity(), 0, false)));
BankAccountsListAdapter bankAccountsAdapter = new BankAccountsListAdapter();
var10000 = (RecyclerView)rootView.findViewById(R.id.recyclerBankAccounts);
Intrinsics.checkExpressionValueIsNotNull(var10000, "root.recyclerBankAccounts");
var10000.setAdapter((RecyclerView.Adapter)bankAccountsAdapter);
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView
android:id="#+id/imgLogo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="#dimen/margin_8"
android:layout_marginTop="#dimen/margin_16"
android:layout_marginBottom="#dimen/margin_16"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/fee_logo" />
<android.support.v7.widget.AppCompatTextView
style="#style/BoldTitleStyle"
android:layout_margin="#dimen/margin_8"
android:text="#string/app_name"
app:layout_constraintBottom_toBottomOf="#+id/imgLogo"
app:layout_constraintStart_toEndOf="#id/imgLogo"
app:layout_constraintTop_toTopOf="#+id/imgLogo" />
<android.support.v7.widget.AppCompatImageView
android:id="#+id/imgNotification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_16"
android:layout_marginEnd="#dimen/margin_8"
android:layout_marginBottom="#dimen/margin_16"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_bell_icon" />
<android.support.v7.widget.AppCompatImageView
android:id="#+id/imgBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="#id/imgNotification"
app:layout_constraintTop_toTopOf="#id/imgNotification"
app:srcCompat="#drawable/badge" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/txtBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/margin_8"
android:text="02"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_tiny_8"
app:layout_constraintBottom_toBottomOf="#id/imgBadge"
app:layout_constraintEnd_toEndOf="#id/imgBadge"
app:layout_constraintStart_toStartOf="#id/imgBadge"
app:layout_constraintTop_toTopOf="#id/imgBadge" />
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:padding="#dimen/margin_8"
android:layout_marginBottom="#dimen/margin_8"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/appbar">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.AppCompatTextView
android:id="#+id/txtMyBankAccounts"
style="#style/BoldSubTitleStyle"
android:text="#string/title_my_bank_accounts"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerBankAccounts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="#+id/cardReceiveMoney"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtMyBankAccounts" />
<android.support.v7.widget.CardView
android:id="#+id/cardSendMoney"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_8"
android:layout_marginTop="#dimen/margin_16"
android:layout_marginRight="#dimen/margin_4"
android:layout_marginBottom="#dimen/margin_16"
app:cardCornerRadius="#dimen/margin_16"
app:layout_constraintEnd_toStartOf="#+id/cardReceiveMoney"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/recyclerBankAccounts">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="#dimen/margin_8">
<ImageView
android:id="#+id/imgSendMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_8"
android:layout_marginEnd="#dimen/margin_8"
android:background="#drawable/send_money_icon"
android:padding="#dimen/margin_8"
app:srcCompat="#drawable/ic_arrow_forward" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/poppins_bold"
android:padding="#dimen/margin_8"
android:text="#string/msg_send_money"
android:textColor="#color/colorSecondary" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardReceiveMoney"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_4"
android:layout_marginTop="#dimen/margin_16"
android:layout_marginRight="#dimen/margin_8"
android:layout_marginBottom="#dimen/margin_16"
app:cardCornerRadius="#dimen/margin_16"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="#+id/cardSendMoney"
app:layout_constraintTop_toBottomOf="#id/recyclerBankAccounts">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="#dimen/margin_8">
<ImageView
android:id="#+id/imgReceiveMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_8"
android:layout_marginEnd="#dimen/margin_8"
android:background="#drawable/receive_money_icon"
android:padding="#dimen/margin_8"
app:srcCompat="#drawable/ic_arrow_back" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/poppins_bold"
android:padding="#dimen/margin_8"
android:text="#string/msg_receive_money"
android:textColor="#color/colorSecondary" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.AppCompatTextView
android:id="#+id/txtSendMoneyTo"
style="#style/BoldSubTitleStyle"
android:layout_marginTop="#dimen/margin_22"
android:text="#string/label_send_money_to"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/cardSendMoney" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/txtSendMoneyToViewAll"
style="#style/BoldSubTitleStyle"
android:layout_margin="#dimen/margin_8"
android:fontFamily="#font/poppins_medium"
android:text="#string/label_view_all"
android:textSize="#dimen/text_small_14"
app:layout_constraintBaseline_toBaselineOf="#+id/txtSendMoneyTo"
app:layout_constraintEnd_toEndOf="#id/cardReceiveMoney" />
<android.support.v7.widget.CardView
android:id="#+id/linearSendMoneyTo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_8"
app:cardCornerRadius="#dimen/margin_16"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtSendMoneyTo">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<novumlogic.payment.customview.DashboardContactItem
android:id="#+id/imgAddContact"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_8"
app:contactImage="#drawable/ic_add_circle"
app:contactName="Add New"
app:hasBackgroundRing="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/contactItem1"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<novumlogic.payment.customview.DashboardContactItem
android:id="#+id/contactItem1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_8"
app:contactImage="#drawable/ic_avatar"
app:contactName="Alice"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/contactItem2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="#+id/imgAddContact"
app:layout_constraintTop_toTopOf="parent" />
<novumlogic.payment.customview.DashboardContactItem
android:id="#+id/contactItem2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_8"
app:contactImage="#drawable/ic_avatar"
app:contactName="Bob"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/contactItem3"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="#+id/contactItem1"
app:layout_constraintTop_toTopOf="parent" />
<novumlogic.payment.customview.DashboardContactItem
android:id="#+id/contactItem3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_8"
app:contactImage="#drawable/ic_avatar"
app:contactName="Emily"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/imgViewMore"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="#+id/contactItem2"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v7.widget.AppCompatImageView
android:id="#+id/imgViewMore"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="#+id/contactItem3"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_keyboard_arrow_right" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/collaps"
android:fitsSystemWindows="true"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
>
<FrameLayout
android:id="#+id/institutions_tab_fragments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.cooltechworks.views.shimmer.ShimmerRecyclerView
android:id="#+id/recycler_view_institutions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/noDataFound"
android:visibility="invisible"
>
<include
layout="#layout/no_data_found"
>
</include>
</LinearLayout>
</FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</android.support.constraint.ConstraintLayout>

Your rootView is null.
Looking at the stacktrace, you're calling initUI() in onCreate(). It is too early. If your rootView is the usual view as inflated in onCreateView(), you need to call initUI() in onCreateView() after inflation, or onViewCreated(), and actually init rootView before that.

Related

RecyclerView catch catch onItemClickListener

I have 2 RecyclerViews that uses the same XML file to inflate views through the adapter.
One RecyclerView does catch clicks while the other doesn't.
The first RecyclerView is on another fragment and the code is similar to the second RecyclerView.
I have tried a lot of changes to the XML file(MaterialCardView) such as removing clickable attribute or changing the layout_weight to be 1 on the card but all of them didn't work.
Also, I can't understand why it would work only on 1 with the same settings on the other.
Here is the code for the second part which is not working:
Fragment - section of matter
list = view.findViewById(R.id.user_display_details_rv); //Getting the RecyclerView
list.setHasFixedSize(true);
int numOfColumns = 2;
list.setLayoutManager(new GridLayoutManager(getContext(), numOfColumns,GridLayoutManager.VERTICAL,false));
adapter = new UserDisplayDetailsAdapter(viewModel,getLayoutInflater());
list.setAdapter(adapter);
list.addItemDecoration(new RecyclerView.ItemDecoration() {
#Override
public void getItemOffsets(#NonNull Rect outRect, #NonNull View view, #NonNull RecyclerView parent, #NonNull RecyclerView.State state) {
outRect.set(5,20,5,20);
}
});
adapter.setOnItemClickListener((v,pos)->{
String pollId = Objects.requireNonNull(viewModel.getUserFilledPolls().get(pos).getPollId());
Navigation.findNavController(v).navigate(FragmentUserDisplayDetailsDirections.actionFragmentUserDisplayDetailsToFragmentOtherUserPoll(pollId,userId));
});
Adapter
public class UserDisplayDetailsAdapter extends RecyclerView.Adapter<UserDisplayDetailsHolder> {
UserDisplayDetailsViewModel viewModel;
LayoutInflater layoutInflater;
OnItemClickListener onItemClickListener;
public UserDisplayDetailsAdapter(UserDisplayDetailsViewModel viewModel, LayoutInflater layoutInflater) {
this.viewModel = viewModel;
this.layoutInflater = layoutInflater;
}
#NonNull
#Override
public UserDisplayDetailsHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = (LayoutInflater) MyApplication.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.poll_list_square,parent,false);
return new UserDisplayDetailsHolder(view,onItemClickListener);
}
#Override
public void onBindViewHolder(#NonNull UserDisplayDetailsHolder holder, int position) {
Poll poll = Objects.requireNonNull(viewModel.getUserFilledPolls().get(position));
holder.bind(poll);
}
#Override
public int getItemCount() {
if(viewModel.getUserFilledPolls() == null){
return 0;
}
return viewModel.getUserFilledPolls().size();
}
public void setOnItemClickListener(OnItemClickListener listener){
this.onItemClickListener = listener;
}
}
Holder
public class UserDisplayDetailsHolder extends RecyclerView.ViewHolder {
MaterialTextView pollsName;
ShapeableImageView icon;
public UserDisplayDetailsHolder(#NonNull View itemView, OnItemClickListener onItemClickListener) {
super(itemView);
pollsName = itemView.findViewById(R.id.homescr_poll_pollName);
icon=itemView.findViewById(R.id.homescr_poll_icon);
itemView.setOnClickListener(v->{
int pos = getAdapterPosition();
onItemClickListener.onItemClick(v,pos);
});
}
public void bind(Poll poll) {
pollsName.setText(poll.getPollName());
}
}
Common XML
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
android:id="#+id/homescr_btn_poll"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:layout_width="110dp"
android:layout_height="90dp"
android:layout_gravity="center"
app:cardBackgroundColor="#color/primeOrng"
app:cardCornerRadius="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:strokeWidth="2dp"
android:theme="#style/Theme.MaterialComponents.Light">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:orientation="horizontal">
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/homescr_poll_mainImage"
android:layout_width="60dp"
android:layout_height="40dp"
android:scaleType="fitStart"
app:strokeWidth="0dp"
app:srcCompat="#drawable/ic_poll" />
<Space
android:id="#+id/homescr_poll_space"
android:layout_width="10dp"
android:layout_height="wrap_content" />
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/homescr_poll_icon"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="end"
app:srcCompat="#drawable/ic_feed_arrow"
app:strokeWidth="0dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<com.google.android.material.textview.MaterialTextView
android:id="#+id/homescr_poll_pollName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="sans-serif-medium"
android:text="#string/poll_name"
android:textAppearance="?attr/textAppearanceHeadline6"
android:textColor="#color/white"
android:textSize="14dp"
android:textStyle="bold" />
</LinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/homescr_poll_doneImage"
android:layout_width="60dp"
android:layout_height="50dp"
android:visibility="gone"
app:srcCompat="#drawable/done_nobg" />
</com.google.android.material.card.MaterialCardView>
Working Fragment XML(Catching clicks on RecyclerView)
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
app:cardElevation="0dp"
app:strokeColor="#color/stroke_color">
tools:context=".FragmentHomeScreen">
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/homeScreen_logo"
android:layout_width="306dp"
android:layout_height="160dp"
android:src="#drawable/logo__nobg_2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/homeScr_text_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:fontFamily="sans-serif-black"
android:gravity="center"
android:text="Hello, "
android:textColor="#color/white"
android:textSize="32dp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/homeScreen_logo" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/homeScr_text_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="80dp"
android:fontFamily="sans-serif-black"
android:gravity="start"
android:text="User Name"
android:maxLines="1"
android:textColor="#color/white"
android:textSize="32dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/homeScr_text_title"
app:layout_constraintTop_toBottomOf="#+id/homeScreen_logo" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/home_layout_const"
android:layout_width="350dp"
android:layout_height="250dp"
android:layout_marginStart="10dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="10dp"
android:foregroundGravity="center_horizontal"
android:paddingLeft="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/homeScr_text_name">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/home_layout_poll_refresh"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/home_poll_rv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scrollbarSize="3dp"
android:scrollbarThumbVertical="#color/white"
android:scrollbars="vertical"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.button.MaterialButton
android:id="#+id/homescr_btn_line"
android:layout_width="350dp"
android:layout_height="10dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="90dp"
android:backgroundTint="#978F8F"
app:cornerRadius="100px"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="#+id/homescr_btn_feed"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:backgroundTint="#color/black"
android:drawableTop="#drawable/ic_feed"
android:fontFamily="sans-serif-medium"
android:text="FEED"
android:textColor="#color/primeOrng"
android:textSize="14dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/homescr_btn_map"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/homescr_btn_line"
app:strokeColor="#color/black"
app:strokeWidth="2dp" />
<com.google.android.material.button.MaterialButton
android:id="#+id/homescr_btn_map"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:backgroundTint="#color/black"
android:drawableTop="#drawable/ic_map"
android:fontFamily="sans-serif-medium"
android:text="#string/map"
android:textColor="#color/primeOrng"
android:textSize="14dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/homescr_btn_feed"
app:layout_constraintTop_toBottomOf="#+id/homescr_btn_line"
app:strokeColor="#color/black"
app:strokeWidth="2dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
NOT Working Fragment XML(NOT Catching clicks on RecyclerView)
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
android:scrollbars="vertical"
android:scrollbarSize="3dp"
android:scrollbarStyle="insideInset"
tools:context=".feed.FragmentUserDisplayDetails">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp">
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/user_display_details_img_main"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginStart="8dp"
android:layout_marginTop="15dp"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearanceOverlay="#style/ShapeAppearanceOverlay.App.CornerSize50Percent"
app:srcCompat="#drawable/avatar"
app:strokeColor="#color/white"
app:strokeWidth="1dp" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/user_display_details_txt_username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif-black"
android:gravity="center"
android:text="User Name"
android:textColor="#color/white"
android:textSize="32dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/user_display_details_img_main" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="#+id/user_dusplay_details_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/user_display_details_txt_username">
<com.google.android.material.textview.MaterialTextView
android:id="#+id/user_display_details_txt_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:drawableStart="#drawable/ic_account"
android:drawablePadding="10dp"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:paddingLeft="20dp"
android:text="#string/email"
android:textColor="#color/white"
android:textSize="28dp"
android:textStyle="bold" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/user_display_details_txt_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:drawableStart="#drawable/ic_white_location"
android:drawablePadding="10dp"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:maxLines="2"
android:paddingLeft="20dp"
android:text="address"
android:textColor="#color/white"
android:textSize="28dp"
android:textStyle="bold" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/user_display_details_txt_education"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:drawableStart="#drawable/ic_education"
android:drawablePadding="10dp"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:paddingLeft="20dp"
android:text="education"
android:textColor="#color/white"
android:textSize="28dp"
android:textStyle="bold" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/user_display_details_txt_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:drawableStart="#drawable/sex_icon"
android:drawablePadding="10dp"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:paddingLeft="20dp"
android:text="SEX"
android:textColor="#color/white"
android:textSize="28dp"
android:textStyle="bold" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/user_display_details_poll_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#drawable/textviewbg">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/user_display_details_rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.button.MaterialButton
android:id="#+id/feed_back_btn"
style="#style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
android:backgroundTint="#color/black"
android:fontFamily="sans-serif"
android:text="BACK "
android:textSize="20sp"
app:cornerRadius="35dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/user_dusplay_details_layout"
app:strokeColor="#color/primeOrng"
app:strokeWidth="1dp" />
<ProgressBar
android:id="#+id/user_display_details_progress_bar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

No view found for id for fragment InspectionDetailsFragment

I have the following XML
<?xml version="1.0" encoding="utf-8"?>
<layout>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/fragment_inspection_details_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="#dimen/size_0dp"
android:layout_height="#dimen/size_0dp"
app:layout_constraintBottom_toTopOf="#+id/fragment_inspection_details_buttons_container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/fragment_inspection_details_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/size_16dp"
android:text="#string/details"
android:textAllCaps="true"
android:textColor="#color/gold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="#dimen/size_0dp"
android:layout_height="1dp"
android:layout_margin="#dimen/size_16dp"
android:background="#color/lightGray"
app:layout_constraintBottom_toBottomOf="#+id/fragment_inspection_details_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/fragment_inspection_details_title"
app:layout_constraintTop_toTopOf="#+id/fragment_inspection_details_title" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/fragment_inspection_details_status_til"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="#dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fragment_inspection_details_title">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/fragment_inspection_details_status_tie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="#string/status" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/fragment_inspection_details_start_time_til"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="#dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fragment_inspection_details_status_til">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/fragment_inspection_details_start_time_tie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="#string/start_time" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/fragment_inspection_details_end_time_til"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="#dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fragment_inspection_details_start_time_til">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/fragment_inspection_details_end_time_tie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="#string/end_time" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/fragment_inspection_details_desc_time_til"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="#dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fragment_inspection_details_end_time_til">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/fragment_inspection_details_desc_time_tie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="#string/description" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/fragment_inspection_details_handling_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/size_16dp"
android:text="#string/handling"
android:textAllCaps="true"
android:textColor="#color/gold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fragment_inspection_details_desc_time_til" />
<View
android:layout_width="#dimen/size_0dp"
android:layout_height="1dp"
android:layout_margin="#dimen/size_16dp"
android:background="#color/lightGray"
app:layout_constraintBottom_toBottomOf="#+id/fragment_inspection_details_handling_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/fragment_inspection_details_handling_title"
app:layout_constraintTop_toTopOf="#+id/fragment_inspection_details_handling_title" />
<TextView
android:id="#+id/fragment_inspection_details_outcome_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/size_16dp"
android:text="#string/outcome"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fragment_inspection_details_handling_title" />
<Spinner
android:id="#+id/fragment_inspection_details_outcome_spinner"
android:layout_width="#dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/size_8dp"
android:layout_marginEnd="#dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fragment_inspection_details_outcome_title" />
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="#dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/size_16dp"
android:layout_marginEnd="#dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fragment_inspection_details_outcome_spinner">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/fragment_inspection_details_outcome_report_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Outcome report" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<LinearLayout
android:id="#+id/fragment_inspection_details_buttons_container"
android:layout_width="#dimen/size_0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.appcompat.widget.AppCompatButton
android:layout_width="#dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/size_16dp"
android:layout_weight="1"
android:background="#drawable/white_background_gray_rounded_border"
android:text="#string/save"
android:textAllCaps="false" />
<androidx.appcompat.widget.AppCompatButton
android:layout_width="#dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/size_16dp"
android:layout_weight="1"
android:background="#drawable/white_background_gray_rounded_border"
android:text="#string/handle"
android:textAllCaps="false" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
and the following code -
class InspectionDetailsFragment : Fragment() {
companion object {
fun newInstance(inspection: Inspection): InspectionDetailsFragment {
val inspectionDetailsFragment = InspectionDetailsFragment()
val bundle = Bundle()
bundle.putParcelable(Constants.INSPECTION, inspection)
inspectionDetailsFragment.arguments = bundle
return inspectionDetailsFragment
}
}
...
...
}
//Inside another Fragment
changeFragment(
parentFragmentManager, R.id.fragment_inspection_details_root,
InspectionDetailsFragment.newInstance(inspection), true
)
// Change fragment extension function to handle navigation easily
#SuppressLint("PrivateResource")
fun changeFragment(fragmentManager: FragmentManager?, #IdRes containerId: Int, fragment: Fragment?, addToBackStack: Boolean = false) {
if (fragmentManager == null) return
val fragmentTransaction = fragmentManager.beginTransaction()
if (addToBackStack) fragmentTransaction.addToBackStack(null)
/*fragmentTransaction.setCustomAnimations(
R.anim.abc_fade_in,
R.anim.abc_shrink_fade_out_from_bottom,
R.anim.abc_grow_fade_in_from_bottom,
R.anim.abc_popup_exit
)*/
fragment?.let {
fragmentTransaction
.replace(containerId, it, it::class.java.simpleName)
.commit()
}
}
For some reason when trying to navigate to the InspectionDetailsFragment the app crashes with the No view found for id 0x7f0900df (com.supercom.myapplication:id/fragment_inspection_details_root) for fragment InspectionDetailsFragment I really have no idea what's wrong, I tried to look up but it seems like I am doing everything correct.
The InspectionDetailsFragment used to have a container fragment for it but I deleted it, maybe that is related to the issue I am getting?

mpAndroidChart line chart performance with scrollview

I have line chart inside scrollView, all of my data is 7 points, I have lag by scrolling screen,
I try with nestedScrollview or disable chart accessibility but still I have lag.
when chart has no data, scrollView is very smooth, but when i set data on chart, i have bad scrolling
this is setup class
public class SetupCharts {
public LineData drawChart(Context context, ArrayList<Entry> entries, LineChart chart, String[] labels) {
if (entries.size() > 0) {
//customization dataSet Settings
LineDataSet set = new LineDataSet(entries, "");
set.setAxisDependency(YAxis.AxisDependency.LEFT);
set.setDrawValues(true);
set.setLineWidth(3f);
set.setDrawCircles(true);
set.setValueTextSize(12f);
set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
set.setValueTextColor(context.getResources().getColor(R.color.progress));
set.setColor(context.getResources().getColor(R.color.progress));
set.setCircleColor(context.getResources().getColor(R.color.progress));
//customization chart settings
chart.setNoDataText("No data");
chart.setTouchEnabled(false);
chart.setDragEnabled(false);
chart.setDrawGridBackground(false);
chart.getDescription().setEnabled(false);
chart.setPinchZoom(false);
chart.setNestedScrollingEnabled(false);
chart.getLegend().setEnabled(false);
if (labels != null) {
//customization XAxis settings
XAxis x1 = chart.getXAxis();
x1.setTextColor(context.getResources().getColor(R.color.progress));
x1.setDrawGridLines(false);
x1.setAvoidFirstLastClipping(true);
x1.setPosition(XAxis.XAxisPosition.BOTTOM);
x1.setValueFormatter(new IndexAxisValueFormatter(labels));
x1.setLabelCount(labels.length, true);
}
//customization YAxis settings
YAxis y1 = chart.getAxisLeft();
y1.setDrawLabels(false);
y1.setTextColor(Color.BLACK);
y1.setDrawGridLines(false);
YAxis y2 = chart.getAxisRight();
y2.setEnabled(false);
LineData data = new LineData(set);
//set custom font
Typeface face = Typeface.createFromAsset(context.getAssets(), "Shabnamn.ttf");
data.setValueTypeface(face);
chart.getXAxis().setTypeface(face);
return data;
}else
return null;
}
}
and in activity
public void parseResponse(String response){
ArrayList<Entry> entries = new ArrayList<>();
try {
JSONObject object = new JSONObject(response);
JSONArray array = object.getJSONArray("summary");
labels = new String[array.length()];
int j = 0;
for (int i = array.length() - 1; i >= 0; i--) {
JSONObject object1 = array.getJSONObject(i);
int y = object1.getInt("burnt_calory");
entries.add(new Entry(j, y));
date = object1.getString("at_date");
j++;
}
} catch (JSONException e) {
e.printStackTrace();
Log.i("action response catch", "error");
}
LineData data = new
SetupCharts().drawChart(ActionActivity.this,entries, chart , labels);
chart.setData(data);
chart.animateY(55*35, Easing.Linear);
}
and this is xml file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="ltr">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/constraintLayout"
android:layout_marginBottom="16dp"
android:background="#color/darkWhite"
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp">
<Button
android:id="#+id/btnActionDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/green_btn_border"
android:drawableStart="#drawable/ic_arrow_drop_down_black_24dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/colorWhite"
android:textSize="12sp"
app:layout_constraintWidth_percent="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/txtActionTitle"
android:text="#string/steps"
android:textSize="14sp"
app:layout_constraintTop_toTopOf="#id/btnActionDate"
app:layout_constraintBottom_toBottomOf="#id/btnActionDate"
app:layout_constraintEnd_toEndOf="parent"/>
<ProgressBar
android:id="#+id/progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:elevation="2dp"
android:indeterminate="true"
android:indeterminateTint="#color/progress"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#id/powerSportCard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.cardview.widget.CardView
android:id="#+id/car12"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="20dp"
android:elevation="2dp"
app:cardCornerRadius="8dp"
app:layout_constraintTop_toBottomOf="#+id/btnActionDate">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txtProgress"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:text="#string/daily_activity_amount"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="#+id/arc_progress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.github.lzyzsd.circleprogress.ArcProgress
android:id="#+id/arc_progress"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:arc_angle="230"
app:arc_bottom_text="60 دقیقه"
app:arc_bottom_text_size="20dp"
app:arc_finished_color="#color/progress"
app:arc_text_color="#color/BlackColor"
app:arc_text_size="30dp"
app:arc_unfinished_color="#color/Gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/card13"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="20dp"
android:elevation="2dp"
app:cardCornerRadius="8dp"
app:layout_constraintTop_toBottomOf="#+id/car12">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txtChartTitle"
android:layout_gravity="end"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:text="#string/cal_history"
android:textSize="12sp" />
<com.github.mikephil.charting.charts.LineChart
android:id="#+id/lineChart2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cardView12"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
app:cardCornerRadius="8dp"
app:layout_constraintEnd_toStartOf="#+id/cardView3"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/card13">
<TextView
android:id="#+id/txtCalories"
android:drawableTop="#drawable/ic_carbohydrates"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="8dp"
android:gravity="center" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cardView3"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
app:cardCornerRadius="8dp"
app:layout_constraintEnd_toStartOf="#+id/cardView11"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/cardView12"
app:layout_constraintTop_toTopOf="#+id/cardView12">
<TextView
android:id="#+id/txtKm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableTop="#drawable/ic_racing_car"
android:layout_gravity="center"
android:drawablePadding="8dp"
android:gravity="center" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cardView11"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
app:cardCornerRadius="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/cardView3"
app:layout_constraintTop_toTopOf="#+id/cardView12">
<TextView
android:id="#+id/txtTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableTop="#drawable/ic_alarm_clock"
android:layout_gravity="center"
android:drawablePadding="8dp"
android:gravity="center" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/walkSportCard"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
app:cardCornerRadius="8dp"
app:layout_constraintEnd_toStartOf="#+id/powerSportCard"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView12">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/Types_of_running"
android:textSize="12sp"
android:drawableTop="#drawable/ic_climb"
android:layout_gravity="center"
android:drawablePadding="10dp"
android:gravity="center"
android:paddingBottom="20dp"
android:paddingTop="20dp"/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/powerSportCard"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
app:cardCornerRadius="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/walkSportCard"
app:layout_constraintTop_toTopOf="#+id/walkSportCard">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/Powerful_exercises"
android:textSize="12sp"
android:drawableTop="#drawable/ic_weight"
android:layout_gravity="center"
android:drawablePadding="10dp"
android:gravity="center"
android:paddingBottom="20dp"
android:paddingTop="20dp"/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/dailyCard"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="24dp"
android:layout_weight="1"
app:cardCornerRadius="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/competitionSportCard"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/walkSportCard">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/daily_activity"
android:textSize="12sp"
android:drawableTop="#drawable/ic_bathtub"
android:layout_gravity="center"
android:drawablePadding="10dp"
android:gravity="center"
android:paddingBottom="20dp"
android:paddingTop="20dp"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/competitionSportCard"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
app:cardCornerRadius="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/dailyCard"
app:layout_constraintTop_toTopOf="#+id/dailyCard">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/Competitive_sports"
android:textSize="12sp"
android:drawableTop="#drawable/ic_podium"
android:layout_gravity="center"
android:drawablePadding="10dp"
android:gravity="center"
android:paddingBottom="20dp"
android:paddingTop="20dp"/>
</androidx.cardview.widget.CardView>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/darkWhite"
android:elevation="0dp"
app:layout_constraintTop_toTopOf="parent"
app:popupTheme="#style/AppTheme.PopupOverlay">
</androidx.appcompat.widget.Toolbar>
<FrameLayout
android:id="#+id/sportFrame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:elevation="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

Binary XML file line #2: Error inflating class android.support.constraint.Drawlayout

Hi In the below code I am facing an issue with the following logcat error.
I am created one application which contains left navigation drawer .In that when we click on Help menu from drawer it is showing the below error with crashing the app.At the time of crashing I am getting the below error.
can any one please help me
Logcat:
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.Drawlayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.Drawlayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.Drawlayout" on path: DexPathList[[zip file "/data/app/com.example
HelpActivity.java:
public class HelpActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
Mint.initAndStartSession(this.getApplication(), ConstantUtils.SPLUNK_MINK_KEY);
DrawerLayout txtSendMail;
DrawerLayout txtCall;
DrawerLayout txtEmailFeedback;
DrawerLayout txtWebsite;
txtSendMail=(DrawerLayout)findViewById(R.id.txt_send_mail);
txtCall=(DrawerLayout)findViewById(R.id.txt_call);
txtEmailFeedback=(DrawerLayout)findViewById(R.id.txt_email_feedback);
txtWebsite=(DrawerLayout)findViewById(R.id.txt_website);
txtSendMail.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
String toEmailAddress = "customercare#havells.com";
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ toEmailAddress });
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
}
});
txtEmailFeedback.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
String toEmailAddress = "customercare#havells.com";
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ toEmailAddress });
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
}
});
txtCall.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
String phoneNumnber = "tel:1800103131";
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse(phoneNumnber));
startActivity(callIntent);
}
});
txtWebsite.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Uri uri = Uri.parse("http://smart.havells.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
}
public void BackToGeyser(View view) {
final ImageView viewToAnimate = (ImageView) findViewById(R.id.back_arrow_to_geyser_id);
Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
viewToAnimate.startAnimation(in);
viewToAnimate.setVisibility(View.VISIBLE);
onBackPressed();
}
}
activity_help:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.Drawlayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/chipmonk_background">
<RelativeLayout
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_height"
android:layout_gravity="center_vertical"
android:background="#color/color_toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"
android:onClick="BackToGeyser">
<ImageView
android:id="#+id/back_arrow_to_geyser_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="2dp"
android:background="#drawable/ic_arrow_back"
android:onClick="BackToGeyser" />
</RelativeLayout>
<!--
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25sp"
android:layout_marginTop="2sp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/menu"/>
</RelativeLayout>
-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/help"
android:textColor="#color/white"
android:textSize="#dimen/heading_font_size" />
</RelativeLayout>
</RelativeLayout>
<android.support.constraint.Guideline
android:id="#+id/guideline20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.75" />
<android.support.constraint.Guideline
android:id="#+id/guideline21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />
<android.support.constraint.Guideline
android:id="#+id/guideline22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.35" />
<android.support.constraint.Guideline
android:id="#+id/guideline23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.12" />
<android.support.constraint.Guideline
android:id="#+id/guideline24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.88" />
<TextView
android:id="#+id/textView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_medium"
android:text="24/7 Customer Support"
android:textColor="#android:color/black"
app:layout_constraintStart_toStartOf="#+id/guideline23"
app:layout_constraintTop_toTopOf="#+id/guideline22" />
<android.support.constraint.ConstraintLayout
android:id="#+id/txt_send_mail"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="24dp"
android:layout_marginTop="8dp"
android:background="#drawable/login_button_background"
android:elevation="4dp"
app:layout_constraintBottom_toTopOf="#+id/guideline21"
app:layout_constraintDimensionRatio="w,1.5:1"
app:layout_constraintEnd_toStartOf="#+id/txt_call"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView33">
<ImageView
android:id="#+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="#+id/guideline25"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_message" />
<android.support.constraint.Guideline
android:id="#+id/guideline25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />
<TextView
android:id="#+id/textView34"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="#font/roboto_medium"
android:text="send an email"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/guideline25" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="#+id/txt_call"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="8dp"
android:background="#drawable/login_button_background"
android:elevation="4dp"
app:layout_constraintBottom_toTopOf="#+id/guideline21"
app:layout_constraintDimensionRatio="w,1.5:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/txt_send_mail"
app:layout_constraintTop_toBottomOf="#+id/textView33"
app:layout_constraintVertical_bias="0.0">
<ImageView
android:id="#+id/imageView10"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="#+id/guideline27"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_phone" />
<android.support.constraint.Guideline
android:id="#+id/guideline27"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />
<TextView
android:id="#+id/textView36"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="#font/roboto_medium"
android:text="call us"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/guideline27" />
</android.support.constraint.ConstraintLayout>
<TextView
android:id="#+id/textView38"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:fontFamily="#font/roboto_medium"
android:text="Send feedback on Geyser App "
android:textColor="#android:color/black"
app:layout_constraintStart_toStartOf="#+id/guideline23"
app:layout_constraintTop_toTopOf="#+id/guideline21" />
<android.support.constraint.ConstraintLayout
android:id="#+id/txt_email_feedback"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="8dp"
android:background="#drawable/login_button_background"
android:elevation="4dp"
app:layout_constraintBottom_toTopOf="#+id/guideline20"
app:layout_constraintDimensionRatio="h,1.5:1"
app:layout_constraintEnd_toEndOf="#+id/txt_send_mail"
app:layout_constraintStart_toStartOf="#+id/txt_send_mail"
app:layout_constraintTop_toBottomOf="#+id/textView38">
<ImageView
android:id="#+id/imageView11"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="#+id/guideline1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_message" />
<android.support.constraint.Guideline
android:id="#+id/guideline1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="#font/roboto_medium"
android:text="email us"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/guideline1" />
</android.support.constraint.ConstraintLayout>
<TextView
android:id="#+id/textView39"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto_medium"
android:text="For any further details"
android:textColor="#android:color/black"
app:layout_constraintStart_toStartOf="#+id/guideline23"
app:layout_constraintTop_toTopOf="#+id/guideline20" />
<android.support.constraint.ConstraintLayout
android:id="#+id/txt_website"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:background="#drawable/login_button_background"
android:elevation="4dp"
app:layout_constraintDimensionRatio="1.5:1"
app:layout_constraintEnd_toEndOf="#+id/txt_send_mail"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/txt_send_mail"
app:layout_constraintTop_toBottomOf="#+id/textView39">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="#+id/guideline2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_web" />
<android.support.constraint.Guideline
android:id="#+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="#font/roboto_medium"
android:text="havells india ltd"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/guideline2" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.Drawlayout>
you type casting wrong , make Following changes
ConstraintLayout txtSendMail;
ConstraintLayout txtCall;
ConstraintLayouttxtEmailFeedback;
ConstraintLayout txtWebsite;
txtSendMail=(ConstraintLayout)findViewById(R.id.txt_send_mail);
txtCall=(ConstraintLayout)findViewById(R.id.txt_call);
txtEmailFeedback=(ConstraintLayout)findViewById(R.id.txt_email_feedback);
txtWebsite=(ConstraintLayout)findViewById(R.id.txt_website);

Manage RadioButton without RadioGroup (Click on ParentView)

I have created one XML with 4 CardView contains 4 RadioButton and other layouts as follow:
fragment_list_of_transport.xml
<?xml version="1.0" encoding="utf-8"?>
<layout>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:clickable="true"
android:focusable="true"
android:id="#+id/parent_card_1"
android:layout_width="0dp"
android:background="?attr/selectableItemBackground"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginEnd="#dimen/_5sdp"
app:cardCornerRadius="#dimen/_5sdp"
app:cardElevation="#dimen/_5sdp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/image_view_1"
android:layout_width="match_parent"
android:layout_height="#dimen/dimen_transport_list_height"
android:adjustViewBounds="true"
android:contentDescription="#string/app_name"
android:scaleType="fitXY"
android:src="#drawable/now_courier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<RadioButton
android:id="#+id/radio_button_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="#+id/image_truck_1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/image_truck_1" />
<ImageView
android:id="#+id/image_truck_1"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginStart="16dp"
android:contentDescription="#string/app_name"
app:layout_constraintBottom_toBottomOf="#+id/title_text_view_1"
app:layout_constraintStart_toEndOf="#+id/radio_button_1"
app:layout_constraintTop_toTopOf="#+id/title_text_view_1"
app:srcCompat="#drawable/ic_truck" />
<TextView
android:id="#+id/title_text_view_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:gravity="center_vertical"
android:text="Small express under 10 items"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/image_truck_1"
app:layout_constraintTop_toBottomOf="#+id/image_view_1" />
<Button
android:layout_width="#dimen/_90sdp"
android:layout_height="#dimen/_30sdp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/background_round_colors"
android:paddingLeft="#dimen/_10sdp"
android:paddingRight="#dimen/_10sdp"
android:text="#string/button_next"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
android:textColor="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/title_text_view_1"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/parent_card_2"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginEnd="#dimen/_5sdp"
app:cardCornerRadius="#dimen/_5sdp"
app:cardElevation="#dimen/_5sdp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/parent_card_1">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/image_view_2"
android:layout_width="match_parent"
android:layout_height="#dimen/dimen_transport_list_height"
android:adjustViewBounds="true"
android:contentDescription="#string/app_name"
android:scaleType="fitXY"
android:src="#drawable/now_courier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<RadioButton
android:id="#+id/radio_button_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="#+id/image_truck_2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/image_truck_2" />
<ImageView
android:id="#+id/image_truck_2"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginStart="16dp"
android:contentDescription="#string/app_name"
app:layout_constraintBottom_toBottomOf="#+id/title_text_view_2"
app:layout_constraintStart_toEndOf="#+id/radio_button_2"
app:layout_constraintTop_toTopOf="#+id/title_text_view_2"
app:srcCompat="#drawable/ic_truck" />
<TextView
android:id="#+id/title_text_view_2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:gravity="center_vertical"
android:text="Small express under 10 items"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/image_truck_2"
app:layout_constraintTop_toBottomOf="#+id/image_view_2" />
<Button
android:layout_width="#dimen/_90sdp"
android:layout_height="#dimen/_30sdp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/background_round_colors"
android:paddingLeft="#dimen/_10sdp"
android:paddingRight="#dimen/_10sdp"
android:text="#string/button_next"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
android:textColor="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/title_text_view_2"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:clickable="true"
android:focusable="true"
android:id="#+id/parent_card_3"
android:layout_width="0dp"
android:background="?attr/selectableItemBackground"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginEnd="#dimen/_5sdp"
app:cardCornerRadius="#dimen/_5sdp"
app:cardElevation="#dimen/_5sdp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/parent_card_2">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/image_view_3"
android:layout_width="match_parent"
android:layout_height="#dimen/dimen_transport_list_height"
android:adjustViewBounds="true"
android:contentDescription="#string/app_name"
android:scaleType="fitXY"
android:src="#drawable/now_courier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<RadioButton
android:id="#+id/radio_button_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="#+id/image_truck_3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/image_truck_3" />
<ImageView
android:id="#+id/image_truck_3"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginStart="16dp"
android:contentDescription="#string/app_name"
app:layout_constraintBottom_toBottomOf="#+id/title_text_view_3"
app:layout_constraintStart_toEndOf="#+id/radio_button_3"
app:layout_constraintTop_toTopOf="#+id/title_text_view_3"
app:srcCompat="#drawable/ic_truck" />
<TextView
android:id="#+id/title_text_view_3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:gravity="center_vertical"
android:text="Small express under 10 items"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/image_truck_3"
app:layout_constraintTop_toBottomOf="#+id/image_view_3" />
<Button
android:layout_width="#dimen/_90sdp"
android:layout_height="#dimen/_30sdp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/background_round_colors"
android:paddingLeft="#dimen/_10sdp"
android:paddingRight="#dimen/_10sdp"
android:text="#string/button_next"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
android:textColor="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/title_text_view_3"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:clickable="true"
android:focusable="true"
android:id="#+id/parent_card_4"
android:background="?attr/selectableItemBackground"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginEnd="#dimen/_5sdp"
android:layout_marginBottom="#dimen/_10sdp"
app:cardCornerRadius="#dimen/_5sdp"
app:cardElevation="#dimen/_5sdp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/parent_card_3">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/image_view_4"
android:layout_width="match_parent"
android:layout_height="#dimen/dimen_transport_list_height"
android:adjustViewBounds="true"
android:contentDescription="#string/app_name"
android:scaleType="fitXY"
android:src="#drawable/now_courier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<RadioButton
android:id="#+id/radio_button_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="#+id/image_truck_4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/image_truck_4" />
<ImageView
android:id="#+id/image_truck_4"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginStart="16dp"
android:contentDescription="#string/app_name"
app:layout_constraintBottom_toBottomOf="#+id/title_text_view_4"
app:layout_constraintStart_toEndOf="#+id/radio_button_4"
app:layout_constraintTop_toTopOf="#+id/title_text_view_4"
app:srcCompat="#drawable/ic_truck" />
<TextView
android:id="#+id/title_text_view_4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:gravity="center_vertical"
android:text="Small express under 10 items"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/image_truck_4"
app:layout_constraintTop_toBottomOf="#+id/image_view_4" />
<Button
android:layout_width="#dimen/_90sdp"
android:layout_height="#dimen/_30sdp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/background_round_colors"
android:paddingLeft="#dimen/_10sdp"
android:paddingRight="#dimen/_10sdp"
android:text="#string/button_next"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
android:textColor="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/title_text_view_4"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</layout>
Output:
I want to manage RadioButton on click of both CardView and RadioButton , I have used following code:
/**
* A simple {#link Fragment} subclass.
*/
public class FragmentListTransport extends Fragment implements View.OnClickListener {
FragmentListOfTransportBinding mBinding;
public FragmentListTransport() {
// Required empty public constructor
}
#Override
public View onCreateView(#NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_list_of_transport, container, false);
mBinding.parentCard1.setOnClickListener(this);
mBinding.parentCard2.setOnClickListener(this);
mBinding.parentCard3.setOnClickListener(this);
mBinding.parentCard4.setOnClickListener(this);
return mBinding.getRoot();
}
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.parent_card_1:
mBinding.radioButton1.setChecked(true);
mBinding.radioButton2.setChecked(false);
mBinding.radioButton3.setChecked(false);
mBinding.radioButton4.setChecked(false);
break;
case R.id.parent_card_2:
mBinding.radioButton1.setChecked(false);
mBinding.radioButton2.setChecked(true);
mBinding.radioButton3.setChecked(false);
mBinding.radioButton4.setChecked(false);
break;
case R.id.parent_card_3:
mBinding.radioButton1.setChecked(false);
mBinding.radioButton2.setChecked(false);
mBinding.radioButton3.setChecked(true);
mBinding.radioButton4.setChecked(false);
break;
case R.id.parent_card_4:
mBinding.radioButton1.setChecked(false);
mBinding.radioButton2.setChecked(false);
mBinding.radioButton3.setChecked(false);
mBinding.radioButton4.setChecked(true);
break;
}
}
}
Is there any best way to manage it?
I don't easiest way then following (If you have easy way then I will accept it.):
/**
* A simple {#link Fragment} subclass.
*/
public class FragmentListTransport extends Fragment implements View.OnClickListener {
FragmentListOfTransportBinding mBinding;
public FragmentListTransport() {
// Required empty public constructor
}
#Override
public View onCreateView(#NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_list_of_transport, container, false);
mBinding.parentCard1.setOnClickListener(this);
mBinding.parentCard2.setOnClickListener(this);
mBinding.parentCard3.setOnClickListener(this);
mBinding.parentCard4.setOnClickListener(this);
mBinding.radioButton1.setOnClickListener(this);
mBinding.radioButton2.setOnClickListener(this);
mBinding.radioButton3.setOnClickListener(this);
mBinding.radioButton4.setOnClickListener(this);
return mBinding.getRoot();
}
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.parent_card_1:
case R.id.radio_button_1:
clickedRadioButton(mBinding.radioButton1);
break;
case R.id.parent_card_2:
case R.id.radio_button_2:
clickedRadioButton(mBinding.radioButton2);
break;
case R.id.parent_card_3:
case R.id.radio_button_3:
clickedRadioButton(mBinding.radioButton3);
break;
case R.id.parent_card_4:
case R.id.radio_button_4:
clickedRadioButton(mBinding.radioButton4);
break;
}
}
private void clickedRadioButton(RadioButton radioButton) {
mBinding.radioButton1.setChecked(false);
mBinding.radioButton2.setChecked(false);
mBinding.radioButton3.setChecked(false);
mBinding.radioButton4.setChecked(false);
radioButton.setChecked(true);
}
}
If anyone has easiest way then this, please post answer. I will accept.

Categories

Resources