-3
        dialogAddB =  findViewById(R.id.addCatBtn);

        dialogAddB.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogCatName.getText().toString().isEmpty())
                {
                    dialogCatName.setError("Enter Category Name");
                    return;
                }
                addNewCategory(dialogCatName.getText().toString());
            }
        });

I checked logcat and it shows that the exception is caused by null pointer from the code above

MaxV
  • 2,601
  • 3
  • 18
  • 25
Dazeen
  • 1
  • Does this answer your question? [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Ryan M Sep 22 '21 at 22:24

1 Answers1

0

I don't mean to ask the obvious, but since you mention 'dialogAddB' is null have you verified that the ID is really in the layout AND spelled correctly?

Another thought, but I cannot tell if this might be it; when are you resolving the ID? It's possible that the base view has not been set, which would result in null since the view itself wouldn't have been created.

There isn't enough code to really help other than some high-level suggestions.

Kenneth Argo
  • 1,697
  • 12
  • 19