Reputation: 1217
In my application, I have created a class Base_Activity extending SherlockFragmentActivity in which I have defined an action bar this way (it is a menu bar with three different items):
public class Base_Activity extends SherlockFragmentActivity {
private ActionBar mActionBar;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getSupportMenuInflater().inflate(R.menu.main, menu);
mActionBar = getSupportActionBar();
mActionBar.setDisplayUseLogoEnabled(false);
mActionBar.setDisplayShowCustomEnabled(true);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.home:
Intent i = new Intent(this, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
return true;
case R.id.map:
Intent ii = new Intent(this, MainActivity.class);
ii.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(ii);
return true;
case R.id.favorites:
Intent iii = new Intent(this, FavoritesListView.class);
iii.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(iii);
return true;
default:
return super.onOptionsItemSelected(item);
}
} }
Then I have added this line to set this bar in the bottom of my application :
android:uiOptions="splitActionBarWhenNarrow"
It's working well, so far I don't have any problems : I have my bottom action bar with listener for every button.
I now want to add a top action bar, with a SearchBar (or SearchWidget) and a item opening a submenu in the up-right corner.
My problem is now : at the top of every activity, instead of the useless bar with the name of each activity, I want to have another top bar with :
1/ A search bar
2/ An icon opening a sub-menu in the up-right corner.
Unfortunately, I often read that it's not really possible but many application do use this. I am really having a hard time finding how to add my search bar, which doesn't make sense : I know how to write my query method, I have my databaseAdapter and Helper class, so basically it's just about displaying a simple search bar on the top, putting a listener and sending my query to the database and then display a list view.
Does anyone know something which can do the trick to keep an action bar on the bottom and have a search bar also on the top ? Thanks !
Upvotes: 2
Views: 3247
Reputation: 1030
See my question. I think will answer for your first question. Second is very similar to this what I need.
Upvotes: 0