List of usage examples for android.app ActionBar setBackgroundDrawable
public abstract void setBackgroundDrawable(@Nullable Drawable d);
From source file:org.apps8os.motivator.ui.MoodHistoryActivity.java
/** Called when the activity is first created. */ @Override//from ww w.jav a 2 s . co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mood_history); mDayDataHandler = new DayDataHandler(this); mCurrentSprint = getIntent().getExtras().getParcelable(Sprint.CURRENT_SPRINT); mRes = getResources(); mSprintStartDateInMillis = mCurrentSprint.getStartTime(); mSprintEndDateInMillis = mCurrentSprint.getEndTime(); mDaysInSprint = mCurrentSprint.getDaysInSprint(); ActionBar actionBar = getActionBar(); Calendar mToday = Calendar.getInstance(); UtilityMethods.setToDayStart(mToday); mToday.setFirstDayOfWeek(Calendar.MONDAY); mNumberOfTodayInSprint = mCurrentSprint.getCurrentDayOfTheSprint(); // Check if the sprint is already over. if (mNumberOfTodayInSprint > mDaysInSprint) { mNumberOfTodayInSprint = mDaysInSprint; } actionBar.setSubtitle(mCurrentSprint.getSprintTitle()); actionBar.setTitle(mNumberOfTodayInSprint + " " + getString(R.string.days)); actionBar.setBackgroundDrawable(mRes.getDrawable(R.drawable.action_bar_orange)); mStartDate = Calendar.getInstance(); mStartDate.setFirstDayOfWeek(Calendar.MONDAY); mStartDate.setTimeInMillis(mSprintStartDateInMillis); // Calculate the number of weeks in the sprint mNumberOfWeeksInSprint = mToday.get(Calendar.WEEK_OF_YEAR) - mStartDate.get(Calendar.WEEK_OF_YEAR) + 1; if (mNumberOfWeeksInSprint < 0) { mNumberOfWeeksInSprint = 52 + 1 - mStartDate.get(Calendar.WEEK_OF_YEAR) + mToday.get(Calendar.WEEK_OF_YEAR); } else { } // Sets the default selections as today or this week. mSelectedDay = mNumberOfTodayInSprint - 1; mSelectedWeek = mNumberOfWeeksInSprint - 1; mViewPager = (ViewPager) findViewById(R.id.activity_mood_history_viewpager); titleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); // Page change listener to keep the selected week and day in a member. titleIndicator.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageScrollStateChanged(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageSelected(int arg0) { if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { mSelectedDay = arg0; } else if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { mSelectedWeek = arg0; MoodHistoryWeekFragment fragment = mPagerAdapterWeek.getWeekFragment(arg0); if (fragment != null) { fragment.updateSelectedAttribute(mSelectedAttribute, false); } } } }); setPageTitles(); // Load correct layout and functionality based on orientation if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { loadPortraitView(); } else if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { loadLandscapeView(); } }
From source file:com.example.android.cardreader.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.alternate_main_fragment); //TODO Stop Executing Eden //Globals.executeEden(); getUsers(1);/* w ww .j a v a2 s. co m*/ instance = this; final ActionBar actionBar = getActionBar(); actionBar.setTitle(" TartanHacks"); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg)); actionBar.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg)); actionBar.setDisplayShowHomeEnabled(true); frags.add(new PersonListFrag(Globals.pending)); frags.add(new PersonListFrag(Globals.allUsers)); frags.add(new PersonListFrag(Globals.checkedIn)); mAdapter = new FragmentAdapter(getFragmentManager()); fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View dialogView = View.inflate(instance, R.layout.dialog_signup, null); idField = (EditText) dialogView.findViewById(R.id.andrewIdField); pb = (ProgressBar) dialogView.findViewById(R.id.progress); nameField = (TextView) dialogView.findViewById(R.id.name); scanView = (TextView) dialogView.findViewById(R.id.scan_view); idField.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String id = s.toString(); pb.setVisibility(View.VISIBLE); queryId(id); } @Override public void afterTextChanged(Editable s) { } }); AlertDialog.Builder builder; builder = new AlertDialog.Builder(instance); builder.setView(dialogView); builder.setCancelable(true); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { Globals.adding = false; } }); signupDialog = builder.show(); } }); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(0); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); actionBar.addTab(actionBar.newTab().setText("Pending").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("All").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Checked In").setTabListener(this)); mLoyaltyCardReader = new LoyaltyCardReader(this); // Disable Android Beam and register our card reader callback enableReaderMode(); new UpdateThread().executeOnExecutor(Executors.newSingleThreadExecutor()); }
From source file:com.android.gallery3d.filtershow.FilterShowActivity.java
private void loadXML() { setContentView(R.layout.filtershow_activity); ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(R.layout.filtershow_actionbar); actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.background_screen))); mSaveButton = actionBar.getCustomView(); mSaveButton.setOnClickListener(new OnClickListener() { @Override/*from w w w . j av a 2 s . c o m*/ public void onClick(View view) { saveImage(); } }); mImageShow = (ImageShow) findViewById(R.id.imageShow); mImageViews.add(mImageShow); setupEditors(); mEditorPlaceHolder.hide(); mImageShow.attach(); setupStatePanel(); }
From source file:com.android.gallery3d.v5.filtershow.FilterShowActivity.java
private void loadXML() { setContentView(R.layout.filtershow_activity); ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(LayoutInflater.from(this).inflate(R.layout.filtershow_actionbar, null), new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT)); actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.background_screen))); View v = actionBar.getCustomView(); mEditorCancelButton = v.findViewById(R.id.editor_action_cancel); mEditorCancelButton.setOnClickListener(new View.OnClickListener() { @Override//from w w w. ja v a2 s .c o m public void onClick(View v) { Fragment fragment = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); Fragment editorFrament = fragment.getChildFragmentManager() .findFragmentByTag(CategoryPanel.FRAGMENT_TAG); if (editorFrament instanceof LewaEditorBaseFragment) { ((LewaEditorBaseFragment) editorFrament).restorePreset(); showDefaultImageView(); } onBackPressed(); } }); mEditorApplyButton = v.findViewById(R.id.editor_action_apply); mEditorApplyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Fragment fragment = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); Fragment editorFrament = fragment.getChildFragmentManager() .findFragmentByTag(CategoryPanel.FRAGMENT_TAG); if (editorFrament instanceof EditorPanel) { ((EditorPanel) editorFrament).apply(); if (((EditorPanel) editorFrament).getEditorId() == R.id.editorCrop) { backToMain(); } if (((EditorPanel) editorFrament).getEditorId() != R.id.editorCrop) { onBackPressed(); } } if (editorFrament instanceof CategoryPanel) { backToMain(); } } }); mResetButton = v.findViewById(R.id.filtershow_reset); mResetButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { resetHistory(); } }); mSaveButton = v.findViewById(R.id.filtershow_done); mSaveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { saveImage(); } }); mReturnButton = (ImageButton) actionBar.getCustomView().findViewById(R.id.filtershow_return); mReturnButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); mImageShow = (ImageShow) findViewById(R.id.imageShow); mImageViews.add(mImageShow); setupEditors(); mEditorPlaceHolder.hide(); mImageShow.attach(); setupStatePanel(); }
From source file:com.yattatech.dbtc.activity.MainScreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_main_screen); final int color = getResources().getColor(R.color.grey2); final ActionBar actionBar = getActionBar(); mFilter = new IntentFilter(); mLocaleChangedFilter = new IntentFilter(); mTaskList = (DragSortListView) findViewById(R.id.taskList); mTaskListAdapter = new TaskListAdapter(this); final String appKey = getString(R.string.dropbox_key); final String appSecret = getString(R.string.dropbox_secret); final AppKeyPair pair = new AppKeyPair(appKey, appSecret); final AndroidAuthSession session = new AndroidAuthSession(pair); mDropboxAPI = new DropboxAPI<AndroidAuthSession>(session); mToken = FACADE.getDropBoxToken();// ww w . j a v a 2 s . c o m mTaskList.setAdapter(mTaskListAdapter); mTaskList.setOnItemClickListener(mTaskListListener); mTaskList.setDropListener(mDropListener); mTaskList.setDragScrollProfile(mScrollProfile); mTaskList.setFloatViewManager(new MainViewManager(mTaskList)); mFilter.addAction(ADD_NEW_TASK_ACTION); mFilter.addAction(EDIT_TASK_ACTION); mFilter.addAction(REMOVE_TASK_ACTION); mFilter.addAction(BACKUP_RESTORE_ACTION); mLocaleChangedFilter.addAction(Intent.ACTION_LOCALE_CHANGED); actionBar.setIcon(R.drawable.ic_task); actionBar.setTitle(R.string.app_name); actionBar.setBackgroundDrawable(new ColorDrawable(color)); Broadcaster.registerLocalReceiver(mReceiver, mFilter); registerReceiver(mLocaleChangedReceiver, mLocaleChangedFilter); registerForContextMenu(mTaskList); final List<Task> tasks = FACADE.getTasks(); mTaskListAdapter.setElements(FACADE.restoreDataOrder(tasks)); }
From source file:give_me_coins.dashboard.MainScreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_screen); //create file for shared preference sharedPref = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE); API_key_saved = sharedPref.getString(getString(R.string.saved_api_key), ""); if (sharedPref.getBoolean(getString(R.string.show_ltc), true)) { coin_select = 1;/*w ww . j ava 2 s .c o m*/ } else if (sharedPref.getBoolean(getString(R.string.show_btc), true)) { coin_select = 2; } else if (sharedPref.getBoolean(getString(R.string.show_ftc), true)) { coin_select = 3; } // Start service to receive data //if(mService==null) mService= new GMCService(this,mHandler); if (mPoolService == null) mPoolService = new GMCPoolService(mHandler); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that tabs should be displayed in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // For each of the sections in the app, add a tab to the action bar. // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab(actionBar.newTab().setText("Settings") //.setIcon(R.drawable.settings) .setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Summary") // .setIcon(R.drawable.dashboard) .setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Pool") //.setIcon(R.drawable.news) .setTabListener(this)); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); actionBar.setBackgroundDrawable(new ColorDrawable(R.color.menu_background)); // mViewPager.setCurrentItem(0); if (API_key_saved != null && !API_key_saved.equals("")) { if (!"No api key found".equals(API_key_saved)) { startService(); // change to summary tab if api key is set and everything mViewPager.setCurrentItem(1); } } }
From source file:com.native5.plugins.ActionBarPlugin.java
@Override public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { if (!plugin_actions.contains(action)) { return false; }/*from w ww . ja v a2 s. c om*/ final Activity ctx = (Activity) cordova; if ("isAvailable".equals(action)) { JSONObject result = new JSONObject(); result.put("value", ctx.getWindow().hasFeature(Window.FEATURE_ACTION_BAR)); callbackContext.success(result); return true; } final ActionBar bar = ctx.getActionBar(); if (bar == null) { Window window = ctx.getWindow(); if (!window.hasFeature(Window.FEATURE_ACTION_BAR)) { callbackContext .error("ActionBar feature not available, Window.FEATURE_ACTION_BAR must be enabled!"); } else { callbackContext.error("Failed to get ActionBar"); } return true; } if (menu == null) { callbackContext.error("Options menu not initialised"); return true; } final StringBuffer error = new StringBuffer(); JSONObject result = new JSONObject(); if ("isShowing".equals(action)) { result.put("value", bar.isShowing()); } else if ("getHeight".equals(action)) { result.put("value", bar.getHeight()); } else if ("getDisplayOptions".equals(action)) { result.put("value", bar.getDisplayOptions()); } else if ("getNavigationMode".equals(action)) { result.put("value", bar.getNavigationMode()); } else if ("getSelectedNavigationItem".equals(action)) { result.put("value", bar.getSelectedNavigationIndex()); } else if ("getSubtitle".equals(action)) { result.put("value", bar.getSubtitle()); } else if ("getTitle".equals(action)) { result.put("value", bar.getTitle()); } else { try { JSONException exception = new Runnable() { public JSONException exception = null; public void run() { try { // This is a bit of a hack (should be specific to the request, not global) bases = new String[] { removeFilename(webView.getOriginalUrl()), removeFilename(webView.getUrl()) }; if ("show".equals(action)) { LOG.d("native5-action-bar", "Showing Action Bar"); bar.show(); } else if ("hide".equals(action)) { bar.hide(); } else if ("setMenu".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } menu_definition = args.getJSONArray(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ctx.invalidateOptionsMenu(); } } else if ("setTabs".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } bar.removeAllTabs(); tab_callbacks.clear(); if (!buildTabs(bar, args.getJSONArray(0))) { error.append("Invalid tab bar definition"); } } else if ("setDisplayHomeAsUpEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHomeAsUp can not be null"); return; } bar.setDisplayHomeAsUpEnabled(args.getBoolean(0)); } else if ("setDisplayOptions".equals(action)) { if (args.isNull(0)) { error.append("options can not be null"); return; } final int options = args.getInt(0); bar.setDisplayOptions(options); } else if ("setDisplayShowHomeEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHome can not be null"); return; } bar.setDisplayShowHomeEnabled(args.getBoolean(0)); } else if ("setDisplayShowTitleEnabled".equals(action)) { if (args.isNull(0)) { error.append("showTitle can not be null"); return; } bar.setDisplayShowTitleEnabled(args.getBoolean(0)); } else if ("setDisplayUseLogoEnabled".equals(action)) { if (args.isNull(0)) { error.append("useLogo can not be null"); return; } bar.setDisplayUseLogoEnabled(args.getBoolean(0)); } else if ("setHomeButtonEnabled".equals(action)) { if (args.isNull(0)) { error.append("enabled can not be null"); return; } bar.setHomeButtonEnabled(args.getBoolean(0)); } else if ("setIcon".equals(action)) { if (args.isNull(0)) { error.append("icon can not be null"); return; } Drawable drawable = getDrawableForURI(args.getString(0)); bar.setIcon(drawable); } else if ("setListNavigation".equals(action)) { JSONArray items = null; if (args.isNull(0) == false) { items = args.getJSONArray(0); } navigation_adapter.setItems(items); bar.setListNavigationCallbacks(navigation_adapter, navigation_listener); } else if ("setLogo".equals(action)) { String uri = args.getString(0); if (args.isNull(0)) { error.append("logo can not be null"); return; } // try { // InputStream ims = ctx.getAssets().open(uri); Drawable drawable = getDrawableForURI(uri); // Drawable.createFromStream(ims, null); bar.setLogo(drawable); bar.setBackgroundDrawable(getDrawableForURI("images/logo-bg.png")); // } catch (IOException e) { // e.printStackTrace(); // } } else if ("setNavigationMode".equals(action)) { if (args.isNull(0)) { error.append("mode can not be null"); return; } final int mode = args.getInt(0); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } else if ("setSelectedNavigationItem".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } bar.setSelectedNavigationItem(args.getInt(0)); } else if ("setSelectedTab".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } LOG.d("setSelectedTab", bar.getTabCount() + ""); bar.selectTab(bar.getTabAt(args.getInt(0))); } else if ("setSubtitle".equals(action)) { if (args.isNull(0)) { error.append("subtitle can not be null"); return; } bar.setSubtitle(args.getString(0)); } else if ("setTitle".equals(action)) { if (args.isNull(0)) { error.append("title can not be null"); return; } bar.setTitle(args.getString(0)); } } catch (JSONException e) { exception = e; } finally { synchronized (this) { this.notify(); } } } // Run task synchronously { synchronized (this) { ctx.runOnUiThread(this); this.wait(); } } }.exception; if (exception != null) { throw exception; } } catch (InterruptedException e) { error.append("Function interrupted on UI thread"); } } if (error.length() == 0) { if (result.length() > 0) { callbackContext.success(result); } else { callbackContext.success(); } } else { callbackContext.error(error.toString()); } return true; }