Why can't I use findViewById in this file?
Regfragment :
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
public class RegFragment extends Fragment {
EditText text1,text2,text3;
Button btn1;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.reg_layout, container, false);
return rootView;
}
}
and then I tried to make like this:
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
public class RegFragment extends Fragment {
EditText text1,text2,text3;
Button btn1;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.reg_layout, container, false);
return rootView;
text1 = (EditText) findViewById(R.id.text1); -----> ERROR....
}
}
I got error
Is it because I use Fragments ?