@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); frag = (EditorFragment) getFragmentManager().findFragmentById(android.R.id.content); if (frag == null) { frag = new EditorFragment(); getFragmentManager().beginTransaction().add(android.R.id.content, frag).commit(); } if (savedInstanceState != null) { models = savedInstanceState.getCharSequenceArray(KEY_MODELS); } ArrayAdapter<String> nav = null; ActionBar bar = getActionBar(); nav = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, labels); nav.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); bar.setListNavigationCallbacks(nav, this); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_POSITION)); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar to show a dropdown list. final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); final String[] dropdownValues = getResources().getStringArray(R.array.dropdown); // Specify a SpinnerAdapter to populate the dropdown list. ArrayAdapter<String> adapter = new ArrayAdapter<String>( actionBar.getThemedContext(), android.R.layout.simple_spinner_item, android.R.id.text1, dropdownValues); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Set up the dropdown list navigation in the action bar. actionBar.setListNavigationCallbacks(adapter, this); // use getActionBar().getThemedContext() to ensure // that the text color is always appropriate for the action bar // background rather than the activity background. }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); overridePendingTransition(R.anim.fadein, R.anim.fadeout); // .................................... // Load state of filter from Bundle if (savedInstanceState != null) { mSeriesFilter = savedInstanceState.getString("mSeriesFilter"); mFilterMode = savedInstanceState.getInt("mFilterMode"); if (mSeriesFilter == null) mSeriesFilter = ""; // if no filter found } else { // if no state, load in default pref. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String tmp = prefs.getString("libraryFilter", "0"); this.mFilterMode = Integer.parseInt(tmp); } // if // .................................... mThumbPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/OpenComicReader/thumbs/"; mSpinAdapter = new ArrayAdapter<String>( this, android.R.layout.simple_spinner_dropdown_item, this.getResources().getStringArray(R.array.libraryFilter)); // .................................... // Setup Actionbar ActionBar mActionBar = this.getActionBar(); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); mActionBar.setDisplayShowTitleEnabled(false); mActionBar.setListNavigationCallbacks(mSpinAdapter, this); mActionBar.setSelectedNavigationItem(mFilterMode); mActionBar.setDisplayOptions( ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME); mActionBar.setCustomView(R.layout.activity_main_actionbar); mCountLbl = (TextView) mActionBar.getCustomView().findViewById(R.id.lblCount); mSeriesLbl = (TextView) mActionBar.getCustomView().findViewById(R.id.lblSeries); // .................................... // Setup Main View Area mAdapter = new SqlCursorAdapter(this); mAdapter.setItemLayout(R.layout.listitem_main); mGridView = (GridView) findViewById(R.id.lvMain); mGridView.setAdapter(mAdapter); mGridView.setOnItemClickListener(this); registerForContextMenu(mGridView); // Route event from Activity to View // .................................... // Start DB and Data Loader mDb = new Sqlite(this); mDb.openRead(); getSupportLoaderManager().initLoader(0, null, this); } // func
public void enableClusterMenu(int action, ClusterRunner runner) { if (mActionBar != null) { // Don't set cluster runner until action bar is ready. mClusterRunner = null; mActionBar.setListNavigationCallbacks(mAdapter, this); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); setSelectedAction(action); mClusterRunner = runner; } }
/** * 注册actionbar的List导航方式 * * @param * @param listener */ @Override public boolean regActionBarListNav( List<? extends ShowTitleListener> data, OnNavigationListener listener) { ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ListNavAdapter adapter = new ListNavAdapter(this, data); actionBar.setListNavigationCallbacks(adapter, listener); return true; } return true; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, data); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); bar.setListNavigationCallbacks(adapter, this); }
public void myOnclick(View view) { switch (view.getId()) { case R.id.actionbar_xialadaohang: ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // 导航模式必须设为NAVIGATION_MODE_LIST actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener); break; case R.id.actionbar_caozuoshitu: break; case R.id.actionbar_daohangxuanxiang: Intent intent = new Intent(this, TabActionActivity.class); startActivity(intent); break; } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ActionBar actionBar = getActionBar(); // 设置ActionBar是否显示标题 actionBar.setDisplayShowTitleEnabled(true); // 设置导航模式,使用List导航 actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // 为actionBar安装ArrayAdapter actionBar.setListNavigationCallbacks( new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1, android.R.id.text1, new String[] {"第一页", "第二页", "第三页"}), this); }
public void enableAlbumModeMenu(int selected, OnAlbumModeSelectedListener listener) { if (mActionBar != null) { if (mAlbumModeAdapter == null) { // Initialize the album mode options if they haven't been already Resources res = mActivity.getResources(); mAlbumModes = new CharSequence[] { res.getString(R.string.switch_photo_filmstrip), res.getString(R.string.switch_photo_grid) }; mAlbumModeAdapter = new AlbumModeAdapter(); } mAlbumModeListener = null; mLastAlbumModeSelected = selected; mActionBar.setListNavigationCallbacks(mAlbumModeAdapter, this); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); mActionBar.setSelectedNavigationItem(selected); mAlbumModeListener = listener; } }
private void initListNav() { ArrayList<String> items = new ArrayList<String>(); ArrayAdapter<String> nav = null; ActionBar bar = getActionBar(); for (int type : MAP_TYPE_NAMES) { items.add(getString(type)); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { nav = new ArrayAdapter<String>( bar.getThemedContext(), android.R.layout.simple_spinner_item, items); } else { nav = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items); } nav.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); bar.setListNavigationCallbacks(nav, this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar to show a dropdown list. final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // Set up the dropdown list navigation in the action bar. actionBar.setListNavigationCallbacks( // Specify a SpinnerAdapter to populate the dropdown list. new ArrayAdapter<String>( actionBar.getThemedContext(), android.R.layout.simple_list_item_1, android.R.id.text1, new String[] { getString(R.string.title_section1), getString(R.string.title_section2), getString(R.string.title_section3), }), this); // Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics dm = new DisplayMetrics(); display.getMetrics(dm); System.setProperty("width", String.valueOf(dm.widthPixels)); System.setProperty("height", String.valueOf(dm.heightPixels)); if (System.getProperty("init") == null) { System.setProperty("init", "1"); Intent intent = new Intent(getApplicationContext(), PrototypeActivity.class); intent.putExtra(PrototypeActivity.ACTION, "init"); intent.putExtra(PrototypeActivity.ORDER, 0); startActivity(intent); } }
/** * Creates a set of {@link ActionBar} navigation items for the given string resource IDs. * * <p>This implementation employs {@link ActionBar#NAVIGATION_MODE_LIST}. * * @param navigationResourceIds the array of String resource IDs for the navigation item titles * @since 1.1.0 */ protected void addNavigationItems(final int... navigationResourceIds) { ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); this.navigationResourceIds = navigationResourceIds; String[] stringResources = new String[navigationResourceIds.length]; for (int i = 0; i < navigationResourceIds.length; i++) { stringResources[i] = getString(navigationResourceIds[i]); } ArrayAdapter<String> adapter = NavigationAdapter.newInstance( actionBar.getThemedContext(), R.layout.action_view_title_repo, android.R.id.text1, android.R.layout.simple_spinner_dropdown_item, accountService.getGitHubUsername(this), stringResources); actionBar.setListNavigationCallbacks( adapter, new ActionBar.OnNavigationListener() { @Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { onTabSelected(navigationResourceIds[itemPosition]); return true; } }); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (hasTwoCameras) { final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( actionBar.getThemedContext(), R.array.nav, android.R.layout.simple_list_item_1); actionBar.setListNavigationCallbacks(adapter, this); } else { current = DemoCameraFragment.newInstance(false); getFragmentManager().beginTransaction().replace(R.id.container, current).commit(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar to show a dropdown list. final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // Set up the dropdown list navigation in the action bar. actionBar.setListNavigationCallbacks( // Specify a SpinnerAdapter to populate the dropdown list. new ArrayAdapter<String>( getActionBarThemedContextCompat(), android.R.layout.simple_list_item_1, android.R.id.text1, new String[] { getString(R.string.title_section1), getString(R.string.title_section2), getString(R.string.title_section3), }), this); }
@Override protected void onCreate(Bundle savedInstanceState) { // Must set theme before this super.onCreate(savedInstanceState); Log.d(TAG, "onCreate"); LANDSCAPE_MODE = getResources().getBoolean(R.bool.useLandscapeView); AT_LEAST_ICS = getResources().getBoolean(R.bool.atLeastIceCreamSandwich); AT_LEAST_HC = getResources().getBoolean(R.bool.atLeastHoneycomb); if (savedInstanceState != null) { if (UI_DEBUG_PRINTS) Log.d(TAG, "Reloading state"); currentListId = savedInstanceState.getLong(CURRENT_LIST_ID); currentListPos = savedInstanceState.getInt(CURRENT_LIST_POS); } // Setting theme here readAndSetSettings(); // Set up dropdown navigation ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // Will set cursor in Loader // mSpinnerAdapter = new ExtrasCursorAdapter(this, // R.layout.actionbar_dropdown_item, null, // new String[] { NotePad.Lists.COLUMN_NAME_TITLE }, // new int[] { android.R.id.text1 }, new int[] { -9, -8 }, // new int[] { R.string.show_from_all_lists, R.string.error_title }); mSpinnerAdapter = new ExtrasCursorAdapter( this, R.layout.actionbar_dropdown_item, null, new String[] {NotePad.Lists.COLUMN_NAME_TITLE}, new int[] {android.R.id.text1}, new int[] {ALL_NOTES_ID}, new int[] {R.string.show_from_all_lists}); mSpinnerAdapter.setDropDownViewResource(R.layout.actionbar_dropdown_item); // This will listen for navigation callbacks actionBar.setListNavigationCallbacks(mSpinnerAdapter, this); // XML makes sure notes list is displayed. And editor too in landscape // if (lightTheme) // setContentView(R.layout.fragment_layout_light); // else setContentView(R.layout.fragment_layout); // Set this as delete listener NotesListFragment list = (NotesListFragment) getFragmentManager().findFragmentById(R.id.noteslistfragment); list.setOnDeleteListener(this); this.list = list; // So editor can access it ONDELETELISTENER = this; // Set a default list to open if one is set listIdToSelect = PreferenceManager.getDefaultSharedPreferences(this).getLong(DEFAULTLIST, -1); // Handle the intent first, so we know what to possibly select once the // loader is finished beforeBoot = true; onNewIntent(getIntent()); getLoaderManager().initLoader(0, null, this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_letters); mAdapter = new MyAdapter(getSupportFragmentManager(), current_page, ""); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayAdapter<CharSequence> dropDownAdapter = ArrayAdapter.createFromResource( this, R.array.action_list, android.R.layout.simple_list_item_1); actionBar.setListNavigationCallbacks( dropDownAdapter, new OnNavigationListener() { @Override public boolean onNavigationItemSelected(int spinner_position, long arg1) { // RECREATE // THE // FRAGMENT switch (spinner_position) { case 0: current_page = ""; break; case 1: current_page = "more/"; break; case 2: current_page = "bookmarks"; break; case 3: current_page = "search"; break; case 4: // switch to the send screen... current_page = "send"; break; } mAdapter = new MyAdapter(getSupportFragmentManager(), current_page, ""); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setCurrentItem(1); Log.d( "CurrentPage", current_page + " - " + Integer.toString(spinner_position) + " - /" + mAdapter.getCount()); return true; } }); }
@Override public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) { mNavigationListener = callback; mActionBar.setListNavigationCallbacks(adapter, (callback != null) ? this : null); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); // if (savedInstanceState == null) { // getFragmentManager().beginTransaction() // .add(R.id.container, new PlaceholderFragment()) // .commit(); // } actionBar = getActionBar(); // Hide the action bar title actionBar.setDisplayShowTitleEnabled(false); // Enabling Spinner dropdown navigation actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // Spinner title navigation data navSpinner = new ArrayList<SpinnerNavItem>(); navSpinner.add(new SpinnerNavItem("Local", R.drawable.ic_action_settings)); navSpinner.add(new SpinnerNavItem("My Places", R.drawable.ic_launcher)); navSpinner.add(new SpinnerNavItem("Checkins", R.drawable.ic_action_new)); navSpinner.add(new SpinnerNavItem("Latitude", R.drawable.ic_launcher)); // title drop down adapter adapter = new TitleNavigationAdapter(getApplicationContext(), navSpinner); // assigning the spinner navigation actionBar.setListNavigationCallbacks(adapter, this); layout = new RelativeLayout(getApplicationContext()); up = new KeyButton(getApplicationContext(), KeyEvent.VK_UP); down = new KeyButton(getApplicationContext(), KeyEvent.VK_DOWN); left = new KeyButton(getApplicationContext(), KeyEvent.VK_LEFT); right = new KeyButton(getApplicationContext(), KeyEvent.VK_RIGHT); RelativeLayout.LayoutParams r = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layout.setLayoutParams(r); RelativeLayout.LayoutParams t = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); t.addRule(RelativeLayout.ALIGN_PARENT_TOP); t.addRule(RelativeLayout.RIGHT_OF, left.getId()); up.setLayoutParams(t); RelativeLayout.LayoutParams q = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); q.addRule(RelativeLayout.ALIGN_PARENT_LEFT); // q.addRule(RelativeLayout.LEFT_OF, down.getId()); q.addRule(RelativeLayout.BELOW, up.getId()); left.setLayoutParams(q); RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); p.addRule(RelativeLayout.BELOW, up.getId()); p.addRule(RelativeLayout.RIGHT_OF, left.getId()); down.setLayoutParams(p); RelativeLayout.LayoutParams s = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); s.addRule(RelativeLayout.RIGHT_OF, down.getId()); s.addRule(RelativeLayout.BELOW, up.getId()); right.setLayoutParams(s); layout.addView(up); layout.addView(right); layout.addView(left); layout.addView(down); layout.setBackgroundColor(Color.BLUE); layout.setVisibility(View.VISIBLE); up.setVisibility(View.VISIBLE); down.setVisibility(View.VISIBLE); left.setVisibility(View.VISIBLE); right.setVisibility(View.VISIBLE); setContentView(layout); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set up the action bar to show a dropdown list. actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // Set up the dropdown list navigation in the action bar. String[] titles = NavigationHelper.getTitles(); actionBar.setListNavigationCallbacks( // Specify a SpinnerAdapter to populate the dropdown list. new ArrayAdapter<String>( actionBar.getThemedContext(), R.layout.navigation_list_item, android.R.id.text1, titles), this); mPagerTitle = getPagerTitle(); initFlickerAnimations(); mPagerTitleHander = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case 1: // init show sendEmptyMessage(3); sendEmptyMessageDelayed(2, 2000); break; case 2: // hide page title if (isShowTitle && autoHide) { mPagerTitle.startAnimation(hideAnim); } break; case 3: // show page title if (!isShowTitle) { isShowTitle = true; ViewParent parent = mPagerTitle.getParent(); if (parent == null) { // mViewPager.addView( mPagerTitle, // LayoutParams.MATCH_PARENT, // LayoutParams.WRAP_CONTENT); mViewPager.addView(mPagerTitle); mPagerTitle.startAnimation(showAnim); } } break; } }; }; mPagerTitleHander.sendEmptyMessageDelayed(1, 100); mViewPager.setOnPageChangeListener( new OnPageChangeListener() { @Override public void onPageSelected(int pos) { actionBar.setSelectedNavigationItem(pos); onPageChanged(pos); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) {} @Override public void onPageScrollStateChanged(int state) { Log.d("TestData", "onPageScrollStateChanged state:" + state); if (state == ViewPager.SCROLL_STATE_DRAGGING) { mPagerTitleHander.removeMessages(2); if (autoHide) mPagerTitleHander.sendEmptyMessage(3); } else if (state == ViewPager.SCROLL_STATE_IDLE) { mPagerTitleHander.sendEmptyMessageDelayed(2, 2000); } } }); }