Anonimo Anonimus Anonimo Anonimus - 24 days ago 6
Android Question

OnClick not triggered inside Fragment

Got two empty Activites(A and B), which just hold two fragments inside ViewPager of Activity A.
I do not have code errors, everything seems fine.
When I lunch my app and click on button, nothing happens.I was trying just to log something, but still nothing is happening.

I am using ButterKnife, and so far everything was perfect.I got almost same Fragment and it is performing fine, but OnClick inside Fragment B is not working.I tried to add some more OnClick methods, but none of them worked for me.XML looks good,looks almost same as fragment A.

Fragment B is not complex, it just three TextViews and Button.

Here is code for my fragment B:

public class ForgotPasswordFragmentComplete extends BaseFragment
implements BaseView {

private Realm realm;
private Email model;
AppCompatButton resendEmail;
ForgotPasswordPresenter presenter;

public void resendButton() {

Log.d("ResendOnclick", "Checking OnClickMethod ");
Realm realm2 = getRealm();
RealmQuery<Email> queryUserResend = realm2.where(Email.class);

Email resultResend = queryUserResend.findFirst();
ForgotPasswordPayload forgotPayload = new ForgotPasswordPayload(resultResend.getUsername());


public void onCreate(Bundle savedInstanceState) {

((AndroidApplication) getActivity().getApplication()).getApplicationComponent())
.forgotPasswordCompletedModule(new ForgotPasswordCompletedModule())
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
protected void onCreateViewWidgetInitialization(View view) {

public void onStart() {
public void getEmail(){
Realm realm = getRealm();
RealmQuery<Email> queryUser = realm.where(Email.class);
Email result1 = queryUser.findFirst();
resendEmailTxt = (AutoResizeTextView) getView().findViewById(;
if (resendEmailTxt != null) {
public void onDestroy() {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_forgot_password_fragment_complete, container, false);
protected int getFragmentLayoutId() {
return R.layout.fragment_forgot_password_fragment_complete;


You need to bind the fragment's view object before you can use it. Try putting the following code inside onCreateView() :

View rootView = inflater.inflate(R.layout.fragment_forgot_password_fragment_complete, container, false);
ButterKnife.bind(this, rootView);
return rootView;