List of usage examples for android.app ActionBar setCustomView
public abstract void setCustomView(@LayoutRes int resId);
From source file:com.tweetlanes.android.core.view.ProfileActivity.java
void configureActionBarView() { if (mScreenName != null) { final ActionBar actionBar = getActionBar(); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle("@" + mScreenName); final LayoutInflater inflator = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final int layout = R.layout.profile_title_thin; /*//from ww w . j a v a2s . c o m * // TODO: This is messy, and likely won't work for large screen * devices. Need to come up with a better solution int layout; if * (getResources().getConfiguration().orientation == * Configuration.ORIENTATION_LANDSCAPE) { layout= * R.layout.profile_title_thin; } else { layout = * R.layout.profile_title; } */ final View abView = inflator.inflate(layout, null); final ImageView verified = (ImageView) abView.findViewById(R.id.verifiedImage); verified.setVisibility(mUser != null && mUser.getVerified() ? View.VISIBLE : View.GONE); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(abView); } }
From source file:vn.cybersoft.obs.android.activities.DummyActivity.java
public void setActionBar() { ActionBar mActionBar = getActionBar(); mActionBar.setDisplayShowHomeEnabled(false); mActionBar.setDisplayShowTitleEnabled(false); LayoutInflater mInflater = LayoutInflater.from(this); View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null); TextView tvAppName = (TextView) mCustomView.findViewById(R.id.tvAppName); tvAppName.setText("Droid Battery Booster"); ImageButton ivSearch = (ImageButton) mCustomView.findViewById(R.id.ivSearch); ivSearch.setOnClickListener(new OnClickListener() { @Override//from w w w. j a v a2 s . co m public void onClick(View view) { // slide_me.toggleRightDrawer(); } }); ImageView ivdrawer = (ImageView) mCustomView.findViewById(R.id.ivdrawer); ivdrawer.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // slide_me.toggleLeftDrawer(); if (flag) { mDrawerLayout.openDrawer(Gravity.LEFT); flag = false; } else { mDrawerLayout.closeDrawer(Gravity.LEFT); flag = true; } } }); mActionBar.setCustomView(mCustomView); mActionBar.setDisplayShowCustomEnabled(true); }
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/* w w w . j av a 2 s .c om*/ 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.notriddle.budget.EnvelopesActivity.java
private void configureFragment(Fragment frag) { ActionBar ab = getActionBar(); if (frag instanceof TitleFragment) { TitleFragment tFrag = (TitleFragment) frag; setTitle(tFrag.getTitle());//from ww w. j a v a 2 s . c o m ab.setTitle(getTitle()); boolean isTopLevel = false; for (int i = 0; i != mNavAdapter.getCount(); ++i) { if (mNavAdapter.getItem(i) == frag.getClass()) { mNavDrawer.setItemChecked(i, true); isTopLevel = true; break; } else { mNavDrawer.setItemChecked(i, false); } } mNavToggle.setDrawerIndicatorEnabled(isTopLevel); } else { throw new Error("Top-level fragment must be a TitleFragment"); } if (frag instanceof DialogFragment) { DialogFragment dFrag = (DialogFragment) frag; dFrag.setShowsDialog(false); } if (frag instanceof ColorFragment) { ColorFragment cFrag = (ColorFragment) frag; onColorChange(cFrag.getColor()); } else { onColorChange(0); } if (frag instanceof CustomActionBarFragment) { CustomActionBarFragment cFrag = (CustomActionBarFragment) frag; mCustomActionBarView = cFrag.onCreateActionBarView(getLayoutInflater()); ab.setCustomView(mCustomActionBarView); ab.setDisplayShowTitleEnabled(false); ab.setDisplayShowCustomEnabled(true); } else { mCustomActionBarView = null; ab.setDisplayShowTitleEnabled(true); ab.setDisplayShowCustomEnabled(false); ab.setCustomView(null); } }
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();/* w w w . ja v a2s.com*/ } 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:org.opendatakit.survey.activities.MainMenuActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); PropertiesSingleton props = CommonToolProperties.get(this, getAppName()); int showOption = MenuItem.SHOW_AS_ACTION_IF_ROOM; MenuItem item;// w w w .ja v a2 s. c o m if (currentFragment != ScreenList.WEBKIT) { ActionBar actionBar = getActionBar(); actionBar.setCustomView(R.layout.action_bar); actionBar.setDisplayShowCustomEnabled(true); actionBar.show(); item = menu.add(Menu.NONE, MENU_CLOUD_FORMS, Menu.NONE, R.string.sync); item.setIcon(R.drawable.ic_cached_black_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); item = menu.add(Menu.NONE, MENU_ABOUT, Menu.NONE, R.string.about); item.setIcon(R.drawable.ic_info_outline_black_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } else { ActionBar actionBar = getActionBar(); actionBar.hide(); } return true; }
From source file:com.tweetlanes.android.view.ProfileActivity.java
boolean configureActionBarView() { if (mScreenName != null) { ActionBar actionBar = getActionBar(); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); int layout = R.layout.profile_title_thin; /*// w w w . java 2s . c o m * // TODO: This is messy, and likely won't work for large screen devices. Need to come up with a better solution int layout; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { layout= R.layout.profile_title_thin; } else { layout = R.layout.profile_title; }*/ View profileTitleView = inflator.inflate(layout, null); ((TextView) profileTitleView.findViewById(R.id.screenname)).setText("@" + mScreenName); TextView fullNameTextView = (TextView) profileTitleView.findViewById(R.id.fullname); if (fullNameTextView != null && mUser != null) { fullNameTextView.setText(mUser.getName()); } ImageView verifiedImage = (ImageView) profileTitleView.findViewById(R.id.verifiedImage); verifiedImage.setVisibility(mUser != null && mUser.getVerified() ? View.VISIBLE : View.GONE); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(profileTitleView); } return true; }
From source file:com.shafiq.mytwittle.view.ProfileActivity.java
boolean configureActionBarView() { if (mScreenName != null) { ActionBar actionBar = getActionBar(); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); int layout = R.layout.profile_title_thin; /*/*from ww w .ja v a 2 s. c om*/ * // TODO: This is messy, and likely won't work for large screen * devices. Need to come up with a better solution int layout; if * (getResources().getConfiguration().orientation == * Configuration.ORIENTATION_LANDSCAPE) { layout= * R.layout.profile_title_thin; } else { layout = * R.layout.profile_title; } */ View profileTitleView = inflator.inflate(layout, null); ((TextView) profileTitleView.findViewById(R.id.screenname)).setText("@" + mScreenName); TextView fullNameTextView = (TextView) profileTitleView.findViewById(R.id.fullname); if (fullNameTextView != null && mUser != null) { fullNameTextView.setText(mUser.getName()); } ImageView verifiedImage = (ImageView) profileTitleView.findViewById(R.id.verifiedImage); verifiedImage.setVisibility(mUser != null && mUser.getVerified() ? View.VISIBLE : View.GONE); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(profileTitleView); } return true; }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
public void setActionBar() { try {/*from ww w .j av a 2 s . 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.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 ww w. ja v a 2 s. c o m*/ public void onClick(View view) { Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class); startActivity(faqtivity); } }); }