CannotFindSymbol CannotFindSymbol - 8 months ago 48
Android Question

Android Error using findViewById

I am new to this android application development. I am trying to find textfield using findViewById Eclipse keep asking me to create a new method for findViewById. Here is my code.

public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle SavedInstanceState) {

return inflater.inflate(R.layout.myFragment, container,false);

//find textarea
TextView textArea = (TextView) findViewById(;

Please note i have and myFragment.xml files.

Appreciate your help.

Answer Source

Do it like this:

View v = inflater.inflate(R.layout.myFragment, container,false);

TextView textArea = (TextView) v.findViewById(;

return v;

Moreover, define TextView textArea outside the onCreateView so that its available to other methods too.