Example usage for android.widget ProgressBar setId

List of usage examples for android.widget ProgressBar setId

Introduction

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

Prototype

public void setId(@IdRes int id) 

Source Link

Document

Sets the identifier for this view.

Usage

From source file:app.sunstreak.yourpisd.ClassSwipeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //      requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_class_swipe);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);/* w  w  w .  ja v a  2s.  co  m*/
    }
    ProgressBar spinner = new ProgressBar(this);
    spinner.setIndeterminate(true);
    spinner.setId(R.id.action_bar_spinner);
    spinner.getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
    toolbar.addView(spinner);
    receivedClassIndex = getIntent().getExtras().getInt("classIndex");
    classCount = getIntent().getExtras().getInt("classCount");
    termIndex = getIntent().getExtras().getInt("termIndex");
    studentIndex = getIntent().getExtras().getInt("studentIndex");

    setTitle(TermFinder.Term.values()[termIndex].name);

    session = ((YPApplication) getApplication()).session;

    session.studentIndex = studentIndex;
    student = session.getCurrentStudent();
    classesForTerm = student.getClassesForTerm(termIndex);

    System.out.println(classesForTerm);

    mFragments = new ArrayList<Fragment>();
    for (int i = 0; i < classesForTerm.size(); i++) {
        Bundle args = new Bundle();
        args.putInt(DescriptionFragment.ARG_SECTION_NUMBER, i);
        Fragment fragment = new DescriptionFragment();
        fragment.setArguments(args);
        mFragments.add(fragment);
    }

    // Create the adapter that will return a fragment for each of the 
    // primary sections of the app.

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), mFragments);

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    //      final ActionBar actionBar = getActionBar();
    //      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    /*
    for(int i = 0; i< classCount; i++)
    {
       actionBar.addTab(actionBar.newTab()
       .setText(session.getCurrentStudent()
             .getClassName(session.getCurrentStudent().getClassMatch()[i]))
             .setTabListener(this));
    }
     */

    //      for (int classIndex : classesForTerm)
    //         actionBar.addTab(actionBar.newTab().setText(student.getClassName(student.getClassMatch()[classIndex]))
    //               .setTabListener(this));
    ArrayList<String> temp = new ArrayList<>();
    for (int classIndex : classesForTerm) {
        temp.add(student.getClassName(student.getClassMatch()[classIndex]));
    }

    setUpMaterialTabs(temp);
    //      mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
    //
    //         @Override
    //         public void onPageSelected(int position) {
    //            // on changing the page
    //            // make respected tab selected
    //            actionBar.setSelectedNavigationItem(position);
    //         }
    //
    //         @Override
    //         public void onPageScrolled(int arg0, float arg1, int arg2) {
    //         }
    //
    //         @Override
    //         public void onPageScrollStateChanged(int arg0) {
    //         }
    //      });
    //
    System.out.println("received class index = " + receivedClassIndex);
    if (receivedClassIndex > 0 && receivedClassIndex < classesForTerm.size())
        mViewPager.setCurrentItem(receivedClassIndex);
    // otherwise, current item is defaulted to 0

    //      mViewPager.setOffscreenPageLimit(5);

}

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 ww  .  j ava2  s .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.wit.and.dialog.LoginDialog.java

/**
 * //  w ww. ja v  a2 s .  c o  m
 */
@Override
protected View onCreateBodyView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();

    RelativeLayout layout = new RelativeLayout(context);
    // Apply neutral layout params.
    layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    // Do not allow to apply style to body view.
    // layout.setId(R.id.Dialog_Layout_Body);

    // Create layout for loading view.
    LinearLayout loadingLayout = new LinearLayout(context);
    loadingLayout.setOrientation(LinearLayout.HORIZONTAL);
    loadingLayout.setGravity(Gravity.CENTER_VERTICAL);
    // Allow styling of loading layout as body layout.
    loadingLayout.setId(R.id.And_Dialog_Layout_Body);

    // Create text view for message.
    TextView msgTextView = new TextView(context);
    msgTextView.setId(R.id.And_Dialog_TextView_Message);

    // Create circle progress bar.
    ProgressBar circleProgressBar = new ProgressBar(context);
    circleProgressBar.setId(R.id.And_Dialog_ProgressBar);

    // Build loading view.
    loadingLayout.addView(circleProgressBar, new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    loadingLayout.addView(msgTextView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    loadingLayout.setVisibility(View.GONE);

    // Insert loading layout into main body layout.
    RelativeLayout.LayoutParams loadingLayoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    loadingLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(loadingLayout, loadingLayoutParams);

    // Create layout for edit texts.
    LinearLayout editLayout = new LinearLayout(context);
    editLayout.setOrientation(LinearLayout.VERTICAL);
    editLayout.setId(R.id.And_Dialog_Layout_LoginDialog_EditView);

    // Create edit texts for username and password.
    EditText userEdit = new EditText(context);
    userEdit.setId(R.id.And_Dialog_EditText_Username);
    userEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    EditText passEdit = new EditText(context);
    passEdit.setId(R.id.And_Dialog_EditText_Password);
    passEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

    // Create edit texts divider.
    DialogDivider divider = new DialogDivider(context);
    divider.setId(R.id.And_Dialog_Divider_LoginDialog_EditTexts);

    // Build edit layout.
    editLayout.addView(userEdit, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    editLayout.addView(divider, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    editLayout.addView(passEdit, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    // Add custom layout.
    View customView = onCreateCustomView(inflater, editLayout, savedInstanceState);
    if (customView != null) {
        editLayout.addView(this.mCustomView = customView);
    }

    // Insert edit layout into main body layout.
    RelativeLayout.LayoutParams editLayoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    editLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(editLayout, editLayoutParams);

    return layout;
}