List of usage examples for android.app ActionBar getCustomView
public abstract View getCustomView();
From source file:com.numenta.taurus.instance.InstanceListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); // Create content from resource setContentView(R.layout.activity_instance_list); // Get ListFragment _listFragment = (InstanceListFragment) getFragmentManager().findFragmentById(R.id.instance_list_fragment); // Add Filter menu ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(R.layout.actionbar_filter); _favorites = (RadioGroup) actionBar.getCustomView().findViewById(R.id.filter); if (_favorites != null) { _favorites.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override/*w w w . ja v a2 s. c o m*/ public void onCheckedChanged(RadioGroup group, int checkedId) { if (checkedId == R.id.filter_favorites) { clearNotifications(); _listFragment.filterFavorites(); } else { _listFragment.clearFilter(); } // Write the new viewState to the preferences pref.edit().putInt(TaurusPreferenceConstants.PREF_LAST_VIEW_STATE, checkedId).apply(); } }); int checkedId = R.id.filter_none; try { checkedId = pref.getInt(TaurusPreferenceConstants.PREF_LAST_VIEW_STATE, R.id.filter_none); } catch (ClassCastException e) { // Remove old preference value pref.edit().remove(TaurusPreferenceConstants.PREF_LAST_VIEW_STATE).apply(); } RadioButton button = (RadioButton) _favorites.findViewById(checkedId); if (button != null) { button.setChecked(true); } } } // Handle search queries if (getIntent() != null) { handleIntent(getIntent()); } // Check if we should show the tutorial page boolean skipTutorial = pref.getBoolean(PreferencesConstants.PREF_SKIP_TUTORIAL, false); if (!skipTutorial) { Intent myIntent = new Intent(this, TutorialActivity.class); startActivity(myIntent); overridePendingTransition(0, R.anim.fadeout_animation); } }
From source file:com.android.talkback.tutorial.TutorialLessonFragment.java
@Override public void onResume() { super.onResume(); Activity activity = getActivity();/*from w w w.j a v a2 s .co m*/ if (activity != null) { ActionBar actionBar = activity.getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setCustomView(R.layout.tutorial_action_bar); actionBar.getCustomView().findViewById(R.id.up).setOnClickListener(this); TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.action_bar_title); title.setText(getTitle()); LocalBroadcastManager.getInstance(activity).registerReceiver(mActionMonitor, GestureActionMonitor.FILTER); } TalkBackService service = TalkBackService.getInstance(); if (service != null) { service.addEventListener(mExercise); } }
From source file:se.toxbee.sleepfighter.activity.EditGPSFilterAreaActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupActionBar() { String name = this.printName(); if (Build.VERSION.SDK_INT >= 11) { // add the custom view to the action bar. ActionBar actionBar = getActionBar(); actionBar.setCustomView(R.layout.gpsfilter_area_actionbar); actionBar.setDisplayOptions(//from ww w .ja v a 2 s . c o m ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM); View customView = actionBar.getCustomView(); // Setup edit name component. EditText editNameView = (EditText) customView.findViewById(R.id.edit_gpsfilter_area_title_edit); editNameView.setText(name); editNameView.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { area.setName(GPSFilterTextUtils.printName(getResources(), v.getText().toString())); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); return false; } }); editNameView.clearFocus(); // Setup enabled switch. CompoundButton activatedSwitch = (CompoundButton) customView .findViewById(R.id.edit_gpsfilter_area_toggle); activatedSwitch.setChecked(this.area.isEnabled()); activatedSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { area.setEnabled(isChecked); } }); } else { this.setTitle(name); } }
From source file:org.billthefarmer.tuner.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Find the views, not all may be present spectrum = (Spectrum) findViewById(R.id.spectrum); display = (Display) findViewById(R.id.display); strobe = (Strobe) findViewById(R.id.strobe); status = (Status) findViewById(R.id.status); meter = (Meter) findViewById(R.id.meter); scope = (Scope) findViewById(R.id.scope); // Add custom view to action bar ActionBar actionBar = getActionBar(); actionBar.setCustomView(R.layout.signal_view); actionBar.setDisplayShowCustomEnabled(true); signal = (SignalView) actionBar.getCustomView(); // Create audio audio = new Audio(); // Connect views to audio if (spectrum != null) spectrum.audio = audio;//from www . ja va 2s. co m if (display != null) display.audio = audio; if (strobe != null) strobe.audio = audio; if (status != null) status.audio = audio; if (signal != null) signal.audio = audio; if (meter != null) meter.audio = audio; if (scope != null) scope.audio = audio; // Set up the click listeners setClickListeners(); }
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 a va 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:ca.mimic.apphangar.Settings.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mInstance = this; setContentView(R.layout.activity_settings); prefs = new PrefsGet(getSharedPreferences(getPackageName(), Context.MODE_MULTI_PROCESS)); mContext = this; if (showChangelog(prefs)) { launchChangelog();/*from w w w . j a v a 2s . c om*/ } display = getWindowManager().getDefaultDisplay(); updateDisplayWidth(); myService = new ServiceCall(mContext); myService.setConnection(mConnection); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setTitle(R.string.title_activity_settings); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setCustomView(R.layout.action_spinner); setUpSpinner((Spinner) actionBar.getCustomView().findViewById(R.id.config_spinner)); actionBar.setDisplayShowCustomEnabled(true); mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOffscreenPageLimit(4); mGetFragments = new GetFragments(); mGetFragments.setFm(getFragmentManager()); mGetFragments.setVp(mViewPager); ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }; mViewPager.setOnPageChangeListener(pageChangeListener); for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } pageChangeListener.onPageSelected(GENERAL_TAB); }
From source file:com.geotrackin.gpslogger.GpsMainActivity.java
public void SetUpActionBar() { ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.gps_main_views, android.R.layout.simple_spinner_dropdown_item); actionBar.setListNavigationCallbacks(spinnerAdapter, this); //Reload the user's previously selected view f73 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); actionBar.setSelectedNavigationItem(prefs.getInt("dropdownview", 0)); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(""); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(R.layout.actionbar); ImageButton helpButton = (ImageButton) actionBar.getCustomView().findViewById(R.id.imgHelp); helpButton.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a v a2 s . co m public void onClick(View view) { Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class); startActivity(faqtivity); } }); }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
public void setActionBar() { try {// ww w .j a v a2s .c o m com.actionbarsherlock.app.ActionBar actionBar = getSupportActionBar(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); actionBar.setCustomView(R.layout.chatactionbar); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); pic = (ImageView) actionBar.getCustomView().findViewById(R.id.ab_userpic); name = (TextView) actionBar.getCustomView().findViewById(R.id.ab_userName); LinearLayout backfrChat = (LinearLayout) actionBar.getCustomView().findViewById(R.id.ll_backFromChat); tv_userStatus = (TextView) actionBar.getCustomView().findViewById(R.id.ab_userStatus); LinearLayout ll_userprofile = (LinearLayout) actionBar.getCustomView() .findViewById(R.id.ll_calluserProfile); btn_filetransfer = (Button) actionBar.getCustomView().findViewById(R.id.btnattechment); btn_filetransfer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub viewAttechmentPopup(v); } }); backfrChat.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub callBack(); } }); ll_userprofile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { callUserProfileActivity(); } }); vv = detailFragment.getView(); bodyInput = (EditText) vv.findViewById(R.id.embedded_text_editor); Fl_Emoticon_Holder = (FrameLayout) vv.findViewById(R.id.fl_emojicons); btn_emoticon_show = (ImageButton) vv.findViewById(R.id.ib_enable_emoticon_frame); String user_number = prefs.getString(stored_chatuserNumber, "No Value"); if (user_number.contains("@")) { String[] nu = user_number.split("@"); nu = nu[0].split(":"); user_number = nu[1]; } supportnum = prefs.getString(stored_supportnumber, ""); String nu = detailFragment.stripNumber(user_number); String fileuri = Environment.getExternalStorageDirectory() + "/R4W/ProfilePic/" + nu + ".png"; Log.d("fileuri", fileuri + " !"); Log.d("supportnum", supportnum); Log.d("nu", nu); if (nu.equals(supportnum)) { pic.setImageResource(R.drawable.roaminglogo); } else { File imageDirectoryprofile = new File(fileuri); if (imageDirectoryprofile.exists()) { pic.setImageURI(Uri.parse(fileuri)); } else { pic.setImageResource(R.drawable.ic_contact_picture_180_holo_light); } } String username = nu; if (dbContacts == null) { dbContacts = new DBContacts(MessageActivity.this); } String nameServer = "", nameContact = ""; dbContacts.openToRead(); Cursor cursor = dbContacts.fetch_contact_from_R4W(nu); if (cursor.getCount() > 0) { cursor.moveToFirst(); nameServer = cursor.getString(5).toString(); nameContact = cursor.getString(2).toString(); cursor.close(); dbContacts.close(); Log.d("nameServer", nameServer + " in"); Log.d("nameContact", nameContact + " in"); if (!nameServer.equals("***no name***")) { username = nameServer; } else { username = nameContact; } name.setText(username); } else { name.setText(nu); } } catch (Exception e) { // TODO: handle exception } }
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/* w w w. ja v a 2 s .co 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.android.dialer.DialtactsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.e(TAG, " --- onCreate(Bundle savedInstanceState) --- start "); Trace.beginSection(TAG + " onCreate"); View retView = null;//from www .ja v a 2 s. c om super.onCreateView(inflater, container, savedInstanceState); //?? iControlDeleteBtn = (IControlDeleteBtn) getActivity(); //mFirstLaunch = true; final Resources resources = getResources(); int temp = resources.getDimensionPixelSize(R.dimen.floating_action_button_width); //?actionbar mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large); Trace.beginSection(TAG + " setContentView"); //setContentView(R.layout.dialtacts_activity); retView = inflater.inflate(R.layout.dialtacts_activity, container, false); Trace.endSection(); Trace.beginSection(TAG + " setup Views"); final ActionBar actionBar = getActivity().getActionBar(); //actionbar? //actionBar.setCustomView(R.layout.dialtacts_actionbar); //actionBar.setDisplayShowCustomEnabled(true); TextView actionbarNameTxt = (TextView) actionBar.getCustomView().findViewById(R.id.actionbar_name); actionbarNameTxt.setOnClickListener(this); ImageView actionbarMenu = (ImageView) actionBar.getCustomView().findViewById(R.id.actionbar_menu); actionbarMenu.setOnClickListener(this); TextView editerToCalldetail = (TextView) actionBar.getCustomView() .findViewById(R.id.actionbar_call_dialtacts_action_editer); editerToCalldetail.setOnClickListener(this); TextView cancelTxt = (TextView) actionBar.getCustomView() .findViewById(R.id.actionbar_call_dialtacts_action_cancel); cancelTxt.setOnClickListener(this); actionbarNameTxt.setText(getString(R.string.all_calls)); mSearchView = (EditText) actionBar.getCustomView().findViewById(R.id.edittext); mSearchView.setVisibility(View.GONE); mDialtactsActionBarController = new DialtactsActionBarController(actionbarMenu, editerToCalldetail, cancelTxt, actionbarNameTxt, this); // actionBar.setBackgroundDrawable(null); SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView() .findViewById(R.id.search_view_container); // searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener); // mActionBarController = new DialtactsActionBarController(this, searchEditTextLayout); // mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view); mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); // mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button); // mSearchView.setOnClickListener(mSearchViewOnClickListener); // searchEditTextLayout.findViewById(R.id.search_box_start_search) // .setOnClickListener(mSearchViewOnClickListener); // searchEditTextLayout.setOnClickListener(mSearchViewOnClickListener); // searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() { // @Override // public void onBackButtonClicked() { // onBackPressed(); // } // // @Override // public void onSearchViewClicked() { // // Hide FAB, as the keyboard is shown. //// mFloatingActionButtonController.scaleOut(); // } // }); mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; // ImageButton optionsMenuButton = // (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button); // optionsMenuButton.setOnClickListener(this); // mOverflowMenu = buildOptionsMenu(searchEditTextLayout); // optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); // Add the favorites fragment but only if savedInstanceState is null. Otherwise the // fragment manager is responsible for recreating it. //??? if (savedInstanceState == null) { getChildFragmentManager().beginTransaction() .add(R.id.dialtacts_container, new DialpadFragment(getActivity()), TAG_DIALPAD_FRAGMENT) // .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT) .commit(); } else { mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY); mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI); mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI); mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH); mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN); // mActionBarController.restoreInstanceState(savedInstanceState); } final boolean isLayoutRtl = DialerUtils.isRtl(); //?????? if (mIsLandscape) { //?? mSlideIn = AnimationUtils.loadAnimation(getActivity(), isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right); mSlideOut = AnimationUtils.loadAnimation(getActivity(), isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right); } else { mSlideIn = AnimationUtils.loadAnimation(getActivity(), R.anim.dialpad_slide_in_bottom); mSlideOut = AnimationUtils.loadAnimation(getActivity(), R.anim.dialpad_slide_out_bottom); } // mSlideIn.setInterpolator(AnimUtils.EASE_IN); mSlideOut.setInterpolator(AnimUtils.EASE_OUT); mSlideIn.setAnimationListener(mSlideInListener); mSlideOut.setAnimationListener(mSlideOutListener); Trace.endSection(); Trace.beginSection(TAG + " initialize smart dialing"); mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(getActivity()); SmartDialPrefix.initializeNanpSettings(getActivity()); Trace.endSection(); Trace.endSection(); initFlushHandler(); Log.e(TAG, " onCreate() dialerFragment " + mIsDialpadShown); return retView; }