Example usage for android.widget ProgressBar ProgressBar

List of usage examples for android.widget ProgressBar ProgressBar

Introduction

In this page you can find the example usage for android.widget ProgressBar ProgressBar.

Prototype

public ProgressBar(Context context) 

Source Link

Document

Create a new progress bar with range 0...100 and initial progress of 0.

Usage

From source file:com.googlecode.android_scripting.activity.Main.java

protected void initializeViews() {
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    layout.setGravity(Gravity.CENTER_HORIZONTAL);
    TextView textview = new TextView(this);
    textview.setText(" PhpForAndroid " + version);
    ImageView imageView = new ImageView(this);
    imageView.setImageDrawable(getResources().getDrawable(R.drawable.pfa));
    layout.addView(imageView);/*  w w w  .j a va2s .co m*/
    mButton = new Button(this);
    mAboutButton = new Button(this);
    MarginLayoutParams marginParams = new MarginLayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    final float scale = getResources().getDisplayMetrics().density;
    int marginPixels = (int) (MARGIN_DIP * scale + 0.5f);
    marginParams.setMargins(marginPixels, marginPixels, marginPixels, marginPixels);
    mButton.setLayoutParams(marginParams);
    mAboutButton.setLayoutParams(marginParams);
    layout.addView(textview);
    layout.addView(mButton);
    layout.addView(mAboutButton);

    mProgressLayout = new LinearLayout(this);
    mProgressLayout.setOrientation(LinearLayout.HORIZONTAL);
    mProgressLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mProgressLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);

    LinearLayout bottom = new LinearLayout(this);
    bottom.setOrientation(LinearLayout.HORIZONTAL);
    bottom.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    bottom.setGravity(Gravity.CENTER_VERTICAL);
    mProgressLayout.addView(bottom);

    TextView message = new TextView(this);
    message.setText("   In Progress...");
    message.setTextSize(20);
    message.setTypeface(Typeface.DEFAULT_BOLD);
    message.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    ProgressBar bar = new ProgressBar(this);
    bar.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    bottom.addView(bar);
    bottom.addView(message);
    mProgressLayout.setVisibility(View.INVISIBLE);

    layout.addView(mProgressLayout);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setProgressBarIndeterminateVisibility(false);

    setContentView(layout);
}

From source file:com.gmail.charleszq.picorner.ui.ImageDetailFragment.java

private boolean likePhoto(final MenuItem item) {

    // prepare the animator
    ProgressBar pb = new ProgressBar(getActivity());
    item.setActionView(pb);//from  w  ww  .  j  a  v a2s.c o  m

    switch (mPhoto.getMediaSource()) {
    case PX500:
        if (SPUtil.getPx500OauthTokenSecret(getActivity()) == null) {
            Toast.makeText(getActivity(), getString(R.string.pls_sing_in_first), Toast.LENGTH_SHORT).show();
            return false;
        }
        break;
    case FLICKR:
        if (!SPUtil.isFlickrAuthed(getActivity())) {
            Toast.makeText(getActivity(), getString(R.string.pls_sing_in_first), Toast.LENGTH_SHORT).show();
            return false;
        }
        break;
    case INSTAGRAM:
        if (SPUtil.getInstagramUserId(getActivity()) == null) {
            Toast.makeText(getActivity(), getString(R.string.pls_sing_in_first), Toast.LENGTH_SHORT).show();
            return false;
        }
        break;
    }

    if (mLoadedBitmap == null) {
        return false; // image not loaded yet.
    }

    IGeneralTaskDoneListener<Boolean> lis = new IGeneralTaskDoneListener<Boolean>() {
        @Override
        public void onTaskDone(Boolean result) {
            item.setActionView(null);
            if (result) {
                mUserLikeThePhoto = !mUserLikeThePhoto;
                mPhoto.setUserLiked(mUserLikeThePhoto);
                Activity act = ImageDetailFragment.this.getActivity();
                if (act != null) {
                    act.invalidateOptionsMenu();
                }
                // broadcast messages
                Message msg = new Message(Message.LIKE_PHOTO, mPhoto.getMediaSource(), mPhoto.getId(),
                        mUserLikeThePhoto);
                MessageBus.broadcastMessage(msg);
            } else {
                if (getActivity() != null)
                    Toast.makeText(getActivity(), getString(R.string.msg_like_photo_fail), Toast.LENGTH_SHORT)
                            .show();
            }
        }
    };
    String likeActionString = Boolean.toString(!mUserLikeThePhoto);
    switch (this.mPhoto.getMediaSource()) {
    case FLICKR:
        FlickrLikeTask ftask = new FlickrLikeTask(getActivity(), lis);
        ftask.execute(mPhoto.getId(), likeActionString);
        break;
    case INSTAGRAM:
        InstagramLikePhotoTask igtask = new InstagramLikePhotoTask(getActivity(), lis);
        igtask.execute(mPhoto.getId(), likeActionString);
        break;
    case PX500:
        PxLikePhotoTask pxTask = new PxLikePhotoTask(getActivity());
        pxTask.addTaskDoneListener(lis);
        pxTask.execute(mPhoto.getId(), likeActionString);
        break;
    }
    return true;
}

From source file:com.example.damerap_ver1.IntroVideoActivity.java

/**
* Create the view in which the video will be rendered.
*///from ww w .j  a  v  a  2 s  .com
private void setupView() {
    LinearLayout lLinLayout = new LinearLayout(this);
    lLinLayout.setId(1);
    lLinLayout.setOrientation(LinearLayout.VERTICAL);
    lLinLayout.setGravity(Gravity.CENTER);
    lLinLayout.setBackgroundColor(Color.BLACK);

    LayoutParams lLinLayoutParms = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    lLinLayout.setLayoutParams(lLinLayoutParms);

    this.setContentView(lLinLayout);

    RelativeLayout lRelLayout = new RelativeLayout(this);
    lRelLayout.setId(2);
    lRelLayout.setGravity(Gravity.CENTER);
    lRelLayout.setBackgroundColor(Color.BLACK);
    android.widget.RelativeLayout.LayoutParams lRelLayoutParms = new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lRelLayout.setLayoutParams(lRelLayoutParms);
    lLinLayout.addView(lRelLayout);

    mVideoView = new VideoView(this);
    mVideoView.setId(3);
    android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams = new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mVideoView.setLayoutParams(lVidViewLayoutParams);
    lRelLayout.addView(mVideoView);

    mProgressBar = new ProgressBar(this);
    mProgressBar.setId(4);
    android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms = new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar.setLayoutParams(lProgressBarLayoutParms);
    lRelLayout.addView(mProgressBar);

    mProgressMessage = new TextView(this);
    mProgressMessage.setId(5);
    android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms = new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL);
    lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4);
    mProgressMessage.setLayoutParams(lProgressMsgLayoutParms);
    mProgressMessage.setTextColor(Color.LTGRAY);
    mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_PT, 8);
    mProgressMessage.setText("...");
    lRelLayout.addView(mProgressMessage);
}

From source file:com.cssweb.android.quote.QuoteDetail.java

/**
 * ???/* w  w w  .  ja  v a2s. co  m*/
 */
private void initLoading() {
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    ProgressBar progressBar = new ProgressBar(this);
    progressBar.setPadding(0, 0, 15, 0);
    LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    LayoutParams layoutParams2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.FILL_PARENT);
    layout.addView(progressBar, layoutParams);
    TextView textView = new TextView(this);
    textView.setText(getResources().getText(R.string.cjmx_loading));
    textView.setGravity(Gravity.CENTER_VERTICAL);
    layout.addView(textView, layoutParams2);
    layout.setGravity(Gravity.CENTER);
    loadingLayout = new LinearLayout(this);
    loadingLayout.addView(layout, layoutParams);
    loadingLayout.setGravity(Gravity.CENTER);
    table_1.addView(loadingLayout, 0);
}

From source file:org.apache.cordova.AndroidChromeClient.java

@Override
/**//from ww w  . j  a  v a 2  s.  c o m
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {
        // Create a new Loading view programmatically.

        // create the linear layout
        LinearLayout layout = new LinearLayout(this.appView.getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(this.appView.getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);
        layout.addView(bar);

        mVideoProgressView = layout;
    }
    return mVideoProgressView;
}

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  w  ww  .j a va2  s  .co  m
    progressBar.setLayoutParams(new LinearLayout.LayoutParams(thumbnailWidth, thumbnailHeight));
    return progressBar;
}

From source file:me.piebridge.prevent.ui.UserGuideActivity.java

private void showDonateDialog() {
    RelativeLayout layout = new RelativeLayout(this);
    int pixel = getPixel(0x30);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(pixel, pixel);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(new ProgressBar(this), params);
    donateDialog = ProgressDialog.show(this, null, null);
    donateDialog.setContentView(layout);
    donateDialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, pixel * 0x4);
}

From source file:in.andres.kandroid.ui.TaskEditActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
    case android.R.id.home:
        onBackPressed();/*w w w  .ja  v  a2 s .c  o  m*/
        return true;
    case R.id.action_save:
        ownerId = spinnerProjectUsers.getSelectedItemPosition();
        if (spinnerProjectUsers.getSelectedItemPosition() != 0) {
            for (Enumeration<Integer> iter = projectUsers.keys(); iter.hasMoreElements();) {
                Integer key = iter.nextElement();
                if (projectUsers.get(key).contentEquals((String) spinnerProjectUsers.getSelectedItem())) {
                    ownerId = key;
                    break;
                }
            }
        }
        if (isNewTask) {
            kanboardAPI.createTask(editTextTitle.getText().toString(), projectid,
                    colorId != null ? colorId : defaultColor, columnId, ownerId, null, dueDate,
                    editTextDescription.getText().toString(), null, null, swimlaneId, null, null, null, null,
                    null, null, null, startDate);

        } else {
            kanboardAPI.updateTask(task.getId(), editTextTitle.getText().toString(),
                    colorId != null ? colorId : defaultColor, ownerId, dueDate,
                    editTextDescription.getText().toString(), null, null, null, null, null, null, null, null,
                    null, startDate);
        }
        ProgressBar prog = new ProgressBar(TaskEditActivity.this);
        prog.getIndeterminateDrawable().setColorFilter(Color.WHITE, android.graphics.PorterDuff.Mode.MULTIPLY);
        item.setActionView(prog);
        item.expandActionView();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.commonsware.cwac.masterdetail.MasterDetailHelper.java

/**
 * Override this if you want something else as the
 * "empty view" for the master, in case the list is empty.
 * The default implementation uses a simple ProgressBar.
 * Note that the empty view will be centered within the
 * master. Also note that the empty view should not have a
 * parent, as it will be added to a parent by the
 * framework./* w w  w  .  ja va 2  s . c  o  m*/
 * 
 * @return a View to serve as the "empty view" for the
 *         master list
 */
protected View buildListEmptyView() {
    return (new ProgressBar(getHost()));
}

From source file:org.csploit.android.WifiScannerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    mMenu = menu;//from www  .  jav  a2 s  .co m
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.wifi_scanner, menu);

    if (mScanning) {
        MenuItem menuScan = mMenu.findItem(R.id.scan);
        MenuItemCompat.setActionView(menuScan, new ProgressBar(this));
    }
    return super.onCreateOptionsMenu(menu);
}