material icon indicating copy to clipboard operation
material copied to clipboard

CheckBox clickability

Open LeebeeDev opened this issue 9 years ago • 18 comments

I'm using <com.rey.material.widget.CheckBox android:id="@android:id/checkbox" style="@style/Material.Drawable.CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="16dip" android:clickable="false" android:focusable="false" android:focusableInTouchMode="false" app:cbd_boxSize="18dp"/>

in a custom layout for checkboxpreference. And the checkbox widget still clickable!!. Any idea?

LeebeeDev avatar May 22 '15 02:05 LeebeeDev

Pls try to set android:enabled="false".

rey5137 avatar May 22 '15 03:05 rey5137

I just tried and it doesn't work. Help?

LeebeeDev avatar May 22 '15 03:05 LeebeeDev

Can you please provide all the xml and code you used?

rey5137 avatar May 22 '15 03:05 rey5137

<LinearLayout 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="wrap_content"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingRight="?android:attr/scrollbarSize">

<com.rey.material.widget.CheckBox
    android:id="@android:id/checkbox"
    style="@style/Material.Drawable.CheckBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dip"
    android:clickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    app:cbd_boxSize="18dp" />

<RelativeLayout
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical"
    android:layout_marginBottom="6dip"
    android:layout_marginRight="16dip"
    android:layout_marginTop="6dip"
    android:layout_weight="1"
    android:gravity="end">

    <TextView
        android:id="@+android:id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="marquee"
        android:fadingEdge="horizontal"
        android:singleLine="true"
        android:text="Title"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="?android:attr/textColorPrimary" />

    <TextView
        android:id="@android:id/summary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@android:id/title"
        android:layout_below="@android:id/title"
        android:maxLines="3"
        android:text="subTitle"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>

And in the prefs.xml

<CheckBoxPreference
        android:defaultValue="true"
        android:key="time12"
        android:layout="@layout/checkboxpreference_layout"
        android:summaryOff="@string/_13"
        android:summaryOn="@string/_01"
        android:title="@string/_12Format" />

LeebeeDev avatar May 22 '15 04:05 LeebeeDev

Just curious, do you want to replace the layout of entire Preference, or just the layout of controllable widget portion in this Preference? And why you want to disable checkbox when CheckBoxPreference is for selecting option?

rey5137 avatar May 22 '15 04:05 rey5137

Yes I have to replace the whole layout not only the widget. I want the user to check/uncheck the checkBox by clicking on the whole preference. Right now, when I click on the preference every thing works great, but when click on the checkBox itself it doesn't register the checkedChengeListener at all. you got it?

LeebeeDev avatar May 22 '15 04:05 LeebeeDev

Any help?

LeebeeDev avatar May 23 '15 08:05 LeebeeDev

"com.rey.material.widget.CheckBox cannot be cast to android.widget.CheckBox "
how i can solve this error in java code this error is appear please help

fakak73 avatar Jun 30 '19 03:06 fakak73

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.ClassCastException: com.rey.material.widget.CheckBox cannot be cast to android.widget.CheckBox at com.teamtreehouse.ecomerce.SigninActivity.onCreate(SigninActivity.java:43) at android.app.Activity.performCreate(Activity.java:6876) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)  at android.app.ActivityThread.access$1100(ActivityThread.java:221)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:158)  at android.app.ActivityThread.main(ActivityThread.java:7224)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

fakak73 avatar Jun 30 '19 03:06 fakak73

I used just CheckBox instead com.rey.material.widget.CheckBox. It helps me

DGani avatar Jul 21 '19 18:07 DGani

"com.rey.material.widget.CheckBox cannot be cast to android.widget.CheckBox " how i can solve this error in java code this error is appear please help

Hello, I am facing the same problem pls help me if u have the solution for this . Thankyou!

hanishk avatar Oct 28 '19 14:10 hanishk

Basically you are trying to cast com.rey.materil.widget.CheckBox to android.widget.CheckBox which throws error makes our application to stop suddenly. solution : private com.rey.material.widget.CheckBox chkBoxRememberMe; use the above line while iniatilising your check box and if it shows error later that press alt+enter and import it to com.rey.material.widget.checkBox

thats it . It works for me even i was facing the same issue.

arpitjain1996 avatar Oct 31 '19 22:10 arpitjain1996

Ok thanks

On Fri, Nov 1, 2019, 3:32 AM arpitjain1996 [email protected] wrote:

Basically you are trying to cast com.rey.materil.widget.CheckBox to android.widget.CheckBox which throws error makes our application to stop suddenly. solution : private com.rey.material.widget.CheckBox chkBoxRememberMe; use the above line while iniatilising your check box and if it shows error later that press alt+enter and import it to com.rey.material.widget.checkBox

thats it . It works for me even i was facing the same issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rey5137/material/issues/125?email_source=notifications&email_token=ALWSHVPNVYRH25EAWGXV3PDQRNMINA5CNFSM4BERIUO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECZOL2Q#issuecomment-548595178, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALWSHVJD7PZL3XOELLDSOSDQRNMINANCNFSM4BERIUOQ .

fakak73 avatar Nov 01 '19 13:11 fakak73

Ok thanks On Fri, Nov 1, 2019, 3:32 AM arpitjain1996 @.***> wrote: Basically you are trying to cast com.rey.materil.widget.CheckBox to android.widget.CheckBox which throws error makes our application to stop suddenly. solution : private com.rey.material.widget.CheckBox chkBoxRememberMe; use the above line while iniatilising your check box and if it shows error later that press alt+enter and import it to com.rey.material.widget.checkBox thats it . It works for me even i was facing the same issue. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#125?email_source=notifications&email_token=ALWSHVPNVYRH25EAWGXV3PDQRNMINA5CNFSM4BERIUO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECZOL2Q#issuecomment-548595178>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALWSHVJD7PZL3XOELLDSOSDQRNMINANCNFSM4BERIUOQ .

Also make sure that u use ur own variable name . Dont just copy as mentioned in my solution. Also reply if my solutions works for you

arpitjain1996 avatar Nov 01 '19 13:11 arpitjain1996

Don't import android.widget.CheckBox .. but you should import com.rey.material.widget.CheckBox;

usamaaelgendy avatar Nov 15 '19 00:11 usamaaelgendy

I used just CheckBox instead com.rey.material.widget.CheckBox. It helps me

@DGani thanks

KhushBakhtRehman avatar Dec 29 '19 16:12 KhushBakhtRehman

Basically you are trying to cast com.rey.materil.widget.CheckBox to android.widget.CheckBox which throws error makes our application to stop suddenly. solution : private com.rey.material.widget.CheckBox chkBoxRememberMe; use the above line while iniatilising your check box and if it shows error later that press alt+enter and import it to com.rey.material.widget.checkBox

thats it . It works for me even i was facing the same issue.

It works for me.Thank you :)

syedahmed636 avatar Mar 13 '20 09:03 syedahmed636

Thanks i know that ..

On Fri, Mar 13, 2020, 11:58 AM syedahmed636 [email protected] wrote:

Basically you are trying to cast com.rey.materil.widget.CheckBox to android.widget.CheckBox which throws error makes our application to stop suddenly. solution : private com.rey.material.widget.CheckBox chkBoxRememberMe; use the above line while iniatilising your check box and if it shows error later that press alt+enter and import it to com.rey.material.widget.checkBox

thats it . It works for me even i was facing the same issue.

It works for me.Thank you :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rey5137/material/issues/125#issuecomment-598642702, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALVVFMULLNKNRE4JHLO4JVTRHH7UZANCNFSM4BERIUOQ .

usamaaelgendy avatar Mar 13 '20 10:03 usamaaelgendy