List of usage examples for android.widget ProgressBar setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.egoclean.testpregnancy.util.ActivityHelper.java
/** * Adds an action button to the compatibility action bar, using menu information from a * {@link android.view.MenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's state * can be changed to show a loading spinner using * {@link ActivityHelper#setRefreshActionButtonCompatState(boolean)}. *///from w w w. ja v a2s . co m private View addActionButtonCompatFromMenuItem(final MenuItem item) { final ViewGroup actionBar = getActionBarCompat(); if (actionBar == null) { return null; } // Create the separator ImageView separator = new ImageView(mActivity, null, R.attr.actionbarCompatSeparatorStyle); separator.setLayoutParams(new ViewGroup.LayoutParams(2, ViewGroup.LayoutParams.FILL_PARENT)); // Create the button ImageButton actionButton = new ImageButton(mActivity, null, R.attr.actionbarCompatButtonStyle); actionButton.setId(item.getItemId()); actionButton.setLayoutParams(new ViewGroup.LayoutParams( (int) mActivity.getResources().getDimension(R.dimen.actionbar_compat_height), ViewGroup.LayoutParams.FILL_PARENT)); actionButton.setImageDrawable(item.getIcon()); actionButton.setScaleType(ImageView.ScaleType.CENTER); actionButton.setContentDescription(item.getTitle()); actionButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item); } }); actionBar.addView(separator); actionBar.addView(actionButton); if (item.getItemId() == R.id.menu_refresh) { // Refresh buttons should be stateful, and allow for indeterminate progress indicators, // so add those. int buttonWidth = mActivity.getResources().getDimensionPixelSize(R.dimen.actionbar_compat_height); int buttonWidthDiv3 = buttonWidth / 3; ProgressBar indicator = new ProgressBar(mActivity, null, R.attr.actionbarCompatProgressIndicatorStyle); LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(buttonWidthDiv3, buttonWidthDiv3); indicatorLayoutParams.setMargins(buttonWidthDiv3, buttonWidthDiv3, buttonWidth - 2 * buttonWidthDiv3, 0); indicator.setLayoutParams(indicatorLayoutParams); indicator.setVisibility(View.GONE); indicator.setId(R.id.menu_refresh_progress); actionBar.addView(indicator); } return actionButton; }
From source file:com.money.manager.ex.home.DashboardFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { // add progress bar ProgressBar progressBar = new ProgressBar(getActivity()); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);//from ww w. j a v a 2 s .co m layoutParams.gravity = Gravity.CENTER; progressBar.setLayoutParams(layoutParams); progressBar.setIndeterminate(true); if (id <= ID_LOADER_SCREEN4) { linearScreens[id].removeAllViews(); // add view linearScreens[id].addView(progressBar); } Select query; // start loader switch (id) { case ID_LOADER_SCREEN1: QueryReportIncomeVsExpenses report = new QueryReportIncomeVsExpenses(getActivity()); query = new Select(report.getAllColumns()).where(IncomeVsExpenseReportEntity.Month + "=" + Integer.toString(Calendar.getInstance().get(Calendar.MONTH) + 1) + " AND " + IncomeVsExpenseReportEntity.YEAR + "=" + Integer.toString(Calendar.getInstance().get(Calendar.YEAR))); return new MmxCursorLoader(getActivity(), report.getUri(), query); case ID_LOADER_SCREEN2: query = new Select().where(prepareQueryTopWithdrawals()); return new MmxCursorLoader(getActivity(), new SQLDataSet().getUri(), query); case ID_LOADER_SCREEN3: query = new Select().where(prepareQueryTopPayees()); return new MmxCursorLoader(getActivity(), new SQLDataSet().getUri(), query); case ID_LOADER_SCREEN4: QueryBillDeposits billDeposits = new QueryBillDeposits(getActivity()); query = new Select(billDeposits.getAllColumns()).where(QueryBillDeposits.DAYSLEFT + "<=10") .orderBy(QueryBillDeposits.DAYSLEFT); return new MmxCursorLoader(getActivity(), billDeposits.getUri(), query); } return null; }
From source file:io.github.minime89.passbeam.activities.KeyboardLayoutActivity.java
private void setupKeyboardLayoutMenu() { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { ProgressBar progressBar = new ProgressBar(this); progressBar.setVisibility(View.GONE); progressBar.setIndeterminate(true); ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.END | Gravity.CENTER_VERTICAL); progressBar.setLayoutParams(layoutParams); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(progressBar); }/*from www. ja v a 2s. c om*/ }
From source file:br.org.funcate.dynamicforms.views.GPictureView.java
public ProgressBar getProgressBar(final Context context) { ProgressBar progressBar = new ProgressBar(context); // Get the Drawable custom_progressbar Drawable draw = getResources().getDrawable(R.drawable.customprogressbar); // set the drawable as progress drawable progressBar.setProgressDrawable(draw); progressBar.setVisibility(View.VISIBLE); progressBar.setPadding(5, 5, 5, 5);//from www.ja va2s .c o m progressBar.setLayoutParams(new LinearLayout.LayoutParams(thumbnailWidth, thumbnailHeight)); return progressBar; }
From source file:at.alladin.rmbt.android.map.RMBTMapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.map_google, container, false); registerListeners(view);/*from w ww . j a va2 s . co m*/ final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()); if (errorCode != ConnectionResult.SUCCESS) { final Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode, getActivity(), 0); errorDialog.show(); getFragmentManager().popBackStack(); return view; } View mapView = super.onCreateView(inflater, container, savedInstanceState); final RelativeLayout mapViewContainer = (RelativeLayout) view.findViewById(R.id.mapViewContainer); mapViewContainer.addView(mapView); ProgressBar progessBar = new ProgressBar(getActivity()); final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); progessBar.setLayoutParams(layoutParams); progessBar.setVisibility(View.GONE); view.addView(progessBar); return view; }