Skip to content Skip to sidebar Skip to footer

Correct Way To Call Onclicklistener On Fragments

I'm developing an app that contains a custom dialer fragment. The functionality of this fragment should be the same as the stock dialer. When I push a button, that number appears o

Solution 1:

Declare numTxt as a class member. You have

EditTextnumTxt= (EditText) mRoot.findViewById(R.id.digits);
// local to onCreateView

Change to

EditText numTxt;
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        ViewmRoot= inflater.inflate(R.layout.phone_view, null);

        ImageButtondialBtn= (ImageButton) mRoot.findViewById(R.id.dialButton);
        ImageButtonclearBtn= (ImageButton) mRoot.findViewById(R.id.deleteButton);
        numTxt = (EditText) mRoot.findViewById(R.id.digits);

Edit : To the updated question

As i said in the comments i see nothing wrong with the code posted.

Since you said you can't set text to editext, i just ran your code. For testing purpose i set the launcher icon as background to ImageButton. I modified the ui for testing purpose.

But the logic is the same you used

enter image description here

Post a Comment for "Correct Way To Call Onclicklistener On Fragments"