-1
Hello,
I need to trigger the event click a button that is inside a Fragment
.
I was following the answer of this article, but (excuse my ignorance) it was too complicated for me to understand, because the author of the answer says to create this, create that, but does not say where: if inside the Fragment
or within the MainActivity
or within the Interface itself, at last...
There came a time when I got lost in the explanation.
My project follows the following pattern:
A Main Activity:
<RelativeLayout
...
>
<LinearLayout
...
>
<com.google.android.material.tabs.TabLayout
...>
<com.google.android.material.tabs.TabItem
... />
<com.google.android.material.tabs.TabItem
... />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
...
>
</androidx.viewpager.widget.ViewPager>
</LinearLayout>
Then inside the Fragment
User has a sign up button (btnCadUser
).
Well... I created the Interface, I implemented in MainActivity
, I created the methods, but I’m not able to create the button click event nor instantiate the EditText
from within the Fragment
...
Always returns me null reference, for example:
Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$Onclicklistener)' on a null Object Reference
Thank you very much to anyone who can explain or who has a step by step, because the videos and articles I have found on the Internet assume that the reader is already a skull in Android development.