Hi guys I'm new in android so please help me, I want to build an application android which have 2 fragment tabs :
- Home
- Search
The second fragment should contain 2 more fragments, 1 for searching & 1 for result.
I create a fragment (Search) which contain a simple search view (which I define only in the xml layout)
This is my code :
Main Activity :
public class MDASA extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mdasa);
// add tabs here
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// ...
}
}
Fragment (searching) :
public class FreeOpinion extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment, container, false);
return v;
}
}
Fragment.xml :
<SearchView
android:id="@+id/simpleSearchView"
style="@style/testSearch"
android:queryHint="Search here"/>
I get the search view but it doesn't do any thing. How can I create a second fragment that contain the result of the searching ?
This is the result of my code: a screenshot of my app-1
PS :
I found a question that is similar to mine, but as a result I get a second search view in the ActionBar
a screenshot of my app-2
There is also this code which seems very useful but I don't know where should i put it (because i have to put the search view in the fragment)
Thanx a lot :)