Skip to content Skip to sidebar Skip to footer

Settext Textview Inside Fragment

I have a fragment with a spinner, button and a textview. My spinner has a string of Mansanas and Pakwan. I can't explain it clearly. My code will just explain what i want to do. lo

Solution 1:

You cannot use this line. v in this case is the button you clicked.

Spinnerspinner1= (Spinner) v.findViewById(R.id.spinner1);

Replace that with

Spinnerspinner1= (Spinner) getView().findViewById(R.id.spinner1);

to get the fragment's view.

Solution 2:

You have

publicclassFragmentAextendsFragment {
Spinner spinner1; 

Change this

Spinnerspinner1= (Spinner) v.findViewById(R.id.spinner1);

to

spinner1 = (Spinner) getView().findViewById(R.id.spinner1);

Post a Comment for "Settext Textview Inside Fragment"