3. Action Bar wants to provide
Identifying the app brand
Consistent navigation
Make key actions
3
4. Show Action Bar
<uses-sdk android:minSdkVersion="11" />
<application android:theme="@android:style/Theme.Holo" />
API Level MUST be 11 or greater
theme's android:windowActionBar="true"
, or theme MUST be Holo or its descendants
4
5. Hide Action Bar
Manifest.xml (remove Action Bar)
<application
android:theme="@android:style/Theme.Holo.NoActionBar" />
at Activity
getActionBar().hide();
5
6. App Icon for Navigation
● Go to the app "home" activity
● Navigate "up" the app's structural hierarchy
6
7. App Icon for Navigation (Home)
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
Intent intent = new Intent(this, Main.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return true;
}
} add FLAG_ACTIVITY_CLEAR_TOP
7
27. Navigation - LIST implementation
ArrayAdapter<String> adapter = new
ArrayAdapter<String>(this, R.layout.simple_spinner_item,
R.id.text1, new String[] { "aaa", "bbb" });
adapter.setDropDownViewResource(R.layout.simple_spinner_drop
down_item);
getActionBar().setListNavigationCallbacks(adapter, new
OnNavigationListener() {
boolean onNavigationItemSelected(int position, long id) {
// using position to do something
return true;
}
});
27
29. FragmentFramework
• Action Bar's style
• Navigation mode
• Fragment's callback at CRUD
• App Icon navigation mode
• Swipe all fragments
• Main fragment settings
29
30. Container
public abstract class Container {
public void addFragment(String, Fragment)
public void removeFragment(Fragment)
public void showFragment(Fragment)
public void hideFragment(Fragment)
public void replaceFragment(String, Fragment)
public void onFragmentAdded(FragmentProperty)
public void onFragmentRemoved(FragmentProperty)
public void onFragmentShown(FragmentProperty)
public void onFragmentHidden(FragmentProperty)
public void onFragmentReplaced(FragmentProperty)
}
30
31. Container
public abstract class Container {
public boolean isSliding();
public int getNavigationMode();
public int getAppIconMode();
public abstract Fragment getMainFragment();
public abstract String getMainFragmentName();
}
31
32. Navigation
public interface ListNavigation {
public void setActionBar(ActionBar actionBar);
public int getActionBarLayoutId();
public BaseAdapter getNavigationAdapter();
public interface StandardNavigation extends ListNavigation {
public int getNavigationWidth();
public int getNavigationDirection();
}
}
ListNavigation for LIST
StandardNavigation for STANDARD
32
33. TODO
• TODO standard navigation direction
• TODO communication between fragments
• TODO bulk fragments on creating
• TODO hierarchical fragments
• TODO more generic
• more...
33