0

When I click checkedTextView twice, app fails. there are questions with the same name. But I think my fault is different.

android.content.res.Resources$NotFoundException: Resource ID #0x0

My adapter

@Override
public void onBindViewHolder(@NonNull final CardTasarimTutucu holder, int position) {
    String word = words.get(position);
    holder.rowText.setText(word);
    holder.rowText.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (holder.rowText.isChecked()) {

                holder.rowText.setCheckMarkDrawable(0);
                holder.rowText.setChecked(false);
            } else {
                holder.rowText.setCheckMarkDrawable(R.drawable.ic_check_black_24dp);
                holder.rowText.setChecked(true);
            }
        }
    });
}

Error message

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.sozluk, PID: 2926
android.content.res.Resources$NotFoundException: Resource ID #0x0

at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190)
at android.content.res.Resources.getValue(Resources.java:1290)
at androidx.appcompat.widget.ResourceManagerInternal.createDrawableIfNeeded(ResourceManagerInternal.java:176)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:141)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:132)
at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:104)
at androidx.appcompat.widget.AppCompatCheckedTextView.setCheckMarkDrawable(AppCompatCheckedTextView.java:69)
at com.example.sozluk.CardAdapter$1.onClick(CardAdapter.java:55)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

1 Answer 1

1

Use setCheckMarkDrawable(null) instead of setCheckMarkDrawable(0) to remove the drawable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.