0

I have parent activity with drawerlayout, in it's xml I put dashboard layout using include tag and in xml of this dashboard layout I put 'MainActivity' using include tag again. In the xml of MainActivity there is button, for which in onclick I put some logic in MainActivity.java. Problem is button is rendering, but click is not working anyway

  1. I want to write business logic for click in MainActivity.java, that button which is in xml of MainActivity.xml.
  2. Button click must work in this way
Anand
  • 1
  • 1
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 16 '23 at 07:14
  • Can you provide your code and your java file so that we can answer your question. Actually your question is bit confusing – Mediad Jan 18 '23 at 08:46

1 Answers1

1

Suppose, You have used <include tag in ParentActivty and you have given id as "@+id/layout_button" And also in ChildActivity you have given Button id as "@+id/button"

If you use "viewbinding" in your codebase then you can get the reference of this button by calling binding.layoutButton.button

  • Can you clear me please, is there not any way, that I do keep business logic on click of that button in java file of child activity and button click must work, because currently it is not working in a simple way, as it is indirectly inside parent activity using include tag. If I use viewbinding, I think I will need to write code for click in parent activity java file. I want to keep code modularization. – Anand Jan 15 '23 at 17:27