List of usage examples for android.app ActionBar setCustomView
public abstract void setCustomView(View view, LayoutParams layoutParams);
From source file:com.jiusg.mainscreenshow.ui.MSS.java
/** * ActionBar/* w ww . j av a 2s .co m*/ * * @param layoutId Id */ public void setActionBarLayout(int layoutId) { ActionBar actionBar = getActionBar(); if (null != actionBar) { actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayUseLogoEnabled(false); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(layoutId, null); ActionBar.LayoutParams layout = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); actionBar.setCustomView(v, layout); } }
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 ww . j a v a 2s .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:org.akvo.caddisfly.ui.activity.MainActivity.java
private void setupActionBarSpinner() { ActionBar ab = getActionBar(); ArrayList<TestInfo> tests = null; try {// w w w. ja va 2 s . c o m tests = JsonUtils.loadTests(FileUtils.readRawTextFile(this, R.raw.tests_json)); } catch (JSONException e) { e.printStackTrace(); } mTopLevelSpinnerAdapter.clear(); MainApp mainApp = (MainApp) getApplicationContext(); int selectedIndex = 0; int index = 0; assert tests != null; for (TestInfo test : tests) { mTopLevelSpinnerAdapter.addItem(test.getCode(), test.getName()); if (test.getCode().equalsIgnoreCase(mainApp.currentTestInfo.getCode())) { selectedIndex = index; } index++; } @SuppressLint("InflateParams") View spinnerContainer = LayoutInflater.from(this).inflate(R.layout.actionbar_spinner, null); ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); assert ab != null; ab.setCustomView(spinnerContainer, lp); Spinner spinner = (Spinner) spinnerContainer.findViewById(R.id.actionbar_spinner); spinner.setAdapter(mTopLevelSpinnerAdapter); spinner.setSelection(selectedIndex); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> spinner, View view, int position, long itemId) { MainApp mainApp = (MainApp) getApplicationContext(); String testType = mTopLevelSpinnerAdapter.getTag(position); mainApp.setSwatches(testType); mCalibrateFragment.dataChanged(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); updateActionBarNavigation(getCurrentFragmentIndex()); }
From source file:com.indeema.mail.ui.AbstractActivityController.java
/** * Attach the action bar to the activity. *///w ww. j ava2s .c o m private void attachActionBar() { final ActionBar actionBar = mActivity.getActionBar(); if (actionBar != null && mActionBarView != null) { actionBar.setCustomView(mActionBarView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); // Show a custom view and home icon, keep the title and subttitle final int mask = ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME; actionBar.setDisplayOptions(mask, mask); } mViewMode.addListener(mActionBarView); }
From source file:com.chen.mail.ui.AbstractActivityController.java
/** * Attach the action bar to the activity. *//*from www . j a v a2 s .com*/ private void attachActionBar() { final ActionBar actionBar = mActivity.getActionBar(); if (actionBar != null && mActionBarView != null) { actionBar.setCustomView(mActionBarView, new ActionBar.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); // Show a custom view and home icon, keep the title and subttitle final int mask = ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME; actionBar.setDisplayOptions(mask, mask); } mViewMode.addListener(mActionBarView); }