I am new to Android development.
To create a tabbed Activity, I created three Java classes: 1) About; 2) Search; 3) List;
In my layout for Search I want to have a search bar, so I created an EditText (by drag and drop) and also a Button (by drag and drop).
In order to make my tabs work, in my Search.java I have the following code:
public class Search extends Fragment{
//@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.search, container, false);
return rootView;
}
}
Now in my Search.java class I also want to start working on code for my search bar, but in order to do that I think I need a constructor that starts like this like in a main activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
But when I write code for it, it gives me these errors:
1) on protected
: 'onCreate(Bundle) in 'com.example.alex.project.Search' crashes with 'onCreate(Bundle)' in 'android.support.v4.app.Fragment; attempting to assign weaker access privileges ('protected'); was 'public'
2)on setContentView
: cannot resolve method 'setContentView(int)'
What can I do or what do I need to change to start writing Java code for search bar in 'onCreate(Bundle)' method?
Or do I need to do it somewhere else?
I would really appreciate any help.