Example usage for android.view View setBackgroundColor

List of usage examples for android.view View setBackgroundColor

Introduction

In this page you can find the example usage for android.view View setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:org.anurag.fragments.FileGallery.java

@Override
public void onViewCreated(View v, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(v, savedInstanceState);
    empty = (LinearLayout) v.findViewById(R.id.empty);
    ls = (ListView) v.findViewById(R.id.customListView);
    ls.setSelector(R.drawable.list_selector_hd);
    file_gallery = (LinearLayout) v.findViewById(R.id.file_gallery_layout);
    Utils.setContext(null, getActivity());

    //loading file list at last....
    //this allows other threads of other panel to load first as 
    //they need little time and this thread can take long time and blocking
    //other threads....

    //Utils.load();

    Utils.setView(v);/*from  ww w . j  av a2  s.  c  o  m*/
    is_gallery_opened = false;

    LinearLayout fav = (LinearLayout) v.findViewById(R.id.fav);
    LinearLayout music = (LinearLayout) v.findViewById(R.id.music);
    LinearLayout app = (LinearLayout) v.findViewById(R.id.apps);
    LinearLayout docs = (LinearLayout) v.findViewById(R.id.docs);
    LinearLayout photo = (LinearLayout) v.findViewById(R.id.photos);
    LinearLayout vids = (LinearLayout) v.findViewById(R.id.videos);
    LinearLayout zips = (LinearLayout) v.findViewById(R.id.zips);
    LinearLayout misc = (LinearLayout) v.findViewById(R.id.misc);

    music.setOnClickListener(this);
    fav.setOnClickListener(this);
    app.setOnClickListener(this);
    docs.setOnClickListener(this);
    photo.setOnClickListener(this);
    vids.setOnClickListener(this);
    zips.setOnClickListener(this);
    misc.setOnClickListener(this);

    ls.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            // TODO Auto-generated method stub
            item = (Item) ls.getAdapter().getItem(position);

            if (Constants.LONG_CLICK[0]) {

                if (ITEMS[position] != 1) {
                    ITEMS[position] = 1;
                    arg1.setBackgroundColor(getResources().getColor(R.color.white_grey));
                    ++counter;

                    //updating folder and file count while long press is active....
                    if (item.isDirectory())
                        folder_count++;
                    else
                        file_count++;

                    getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
                } else if (ITEMS[position] == 1) {
                    ITEMS[position] = 0;
                    arg1.setBackgroundColor(Color.WHITE);

                    //updating folder and file count while long press is active....
                    if (item.isDirectory())
                        folder_count--;
                    else
                        file_count--;

                    if (--counter == 0)
                        getActivity().sendBroadcast(new Intent("inflate_normal_menu"));
                    else
                        getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
                }

                return;
            }
            open_locked_item();
        }
    });

    ls.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            boolean sendBroadcast = false;
            item = (Item) ls.getAdapter().getItem(arg2);

            if (ITEMS == null) {
                ITEMS = new int[ls.getAdapter().getCount()];
                sendBroadcast = true;
            }

            if (ITEMS[arg2] != 1) {
                arg1.setBackgroundColor(getResources().getColor(R.color.white_grey));
                ITEMS[arg2] = 1;
                ++counter;

                //updating folder and file count while long press is active....
                if (item.isDirectory())
                    folder_count++;
                else
                    file_count++;

                getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
            } else if (ITEMS[arg2] == 1) {
                ITEMS[arg2] = 0;
                arg1.setBackgroundColor(Color.WHITE);

                //updating folder and file count while long press is active....
                if (item.isDirectory())
                    folder_count--;
                else
                    file_count--;

                if (--counter == 0)
                    getActivity().sendBroadcast(new Intent("inflate_normal_menu"));
                else
                    getActivity().sendBroadcast(new Intent("update_action_bar_long_click"));
            }

            if (sendBroadcast)
                getActivity().sendBroadcast(new Intent("inflate_long_click_menu"));

            return true;
        }
    });

    list_anim_helper = new JazzyHelper(getActivity(), null);
    setAnim(ls);
}

From source file:com.heath_bar.tvdb.SeriesOverview.java

protected void ShowHideEpisodes(View seasonRow) {

    // Get the linear layout that we will be adding/removing the episodes to/from
    LinearLayout epLinearLayout = (LinearLayout) seasonRow;

    if (epLinearLayout.getChildCount() == 1) { // if collapsed, expand (add) the seasons

        TextView seasonText = (TextView) seasonRow.findViewById(R.id.season_text);
        seasonText.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.arrow_down),
                null, null, null);/*from   w w  w .  j  av  a 2  s  .c o  m*/

        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        for (int i = 0; i < episodeList.size(); i++) {
            if (seasonRow.getId() == episodeList.get(i).getSeason()) {
                View episodeView = inflater.inflate(R.layout.episode_text_row, epLinearLayout, false);

                episodeView.setBackgroundColor(
                        AppSettings.listBackgroundColors[i % AppSettings.listBackgroundColors.length]);

                TextView text = (TextView) episodeView.findViewById(R.id.text);
                String nameText = String.format("%02d", episodeList.get(i).getNumber()) + " "
                        + episodeList.get(i).getName();
                text.setText(nameText);
                text.setTextSize(textSize);
                text.setId(episodeList.get(i).getId());

                episodeView.setOnClickListener(episodeListener);
                epLinearLayout.addView(episodeView);
            }
        }
    } else { // else season is expanded, collapse it
        TextView seasonText = (TextView) seasonRow.findViewById(R.id.season_text);
        seasonText.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.arrow_right),
                null, null, null);

        for (int i = epLinearLayout.getChildCount() - 1; i > 0; i--) {
            epLinearLayout.removeView(epLinearLayout.getChildAt(i));
        }

    }

}

From source file:com.rks.musicx.misc.utils.Helper.java

/**
 * Animate view's background color//from w  w  w  . j ava2 s  .c o m
 *
 * @param view
 * @param colorBg
 */
public static void animateViews(Context context, View view, int colorBg) {
    colorAnimation = setAnimator(0xffe5e5e5, colorBg);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            view.setBackgroundColor((Integer) animator.getAnimatedValue());
        }

    });
    colorAnimation.start();
}

From source file:com.smithdtyler.prettygoodmusicplayer.NowPlaying.java

private void setAccentColors(int color) {
    View shuffleBG = findViewById(R.id.shufflebackground);
    View buttonBG = findViewById(R.id.playpausepreviousbackground);
    View spacer1 = findViewById(R.id.spacer1);
    View spacer2 = findViewById(R.id.spacer2);
    if (shuffleBG != null && buttonBG != null && spacer1 != null && spacer2 != null) {
        shuffleBG.setBackgroundColor(color);
        buttonBG.setBackgroundColor(color);
        spacer1.setBackgroundColor(color);
        spacer2.setBackgroundColor(color);
    }/*from   ww w  . j a va 2  s.c  om*/
}

From source file:eu.intermodalics.tango_ros_streamer.activities.RunningActivity.java

private void switchRosLight(final RosStatus status) {
    runOnUiThread(new Runnable() {
        @Override//from  w w w  . ja v  a2 s  .c o  m
        public void run() {
            if (status == RosStatus.UNKNOWN) {
                mRosLightImageView
                        .setImageDrawable(getResources().getDrawable(R.drawable.btn_radio_on_orange_light));
            } else if (status == RosStatus.MASTER_CONNECTED) {
                // Turn ROS light to green.
                mRosLightImageView
                        .setImageDrawable(getResources().getDrawable(R.drawable.btn_radio_on_green_light));
                // Dismiss ROS reconnection snackbar if necessary.
                if (mSnackbarRosReconnection != null && mSnackbarRosReconnection.isShown()) {
                    mSnackbarRosReconnection.dismiss();
                }
                // Set settings icon color to white.
                mToolbarMenu.findItem(R.id.settings).setIcon(R.drawable.ic_settings_white_24dp);
            } else if (status == RosStatus.MASTER_NOT_CONNECTED) {
                // Turn ROS light to red.
                mRosLightImageView
                        .setImageDrawable(getResources().getDrawable(R.drawable.btn_radio_on_red_light));
                // Show snackbar with ROS reconnection button.
                mSnackbarRosReconnection = Snackbar.make(findViewById(android.R.id.content),
                        getString(R.string.snackbar_text_reconnect_ros), Snackbar.LENGTH_INDEFINITE);
                mSnackbarRosReconnection.setAction(getString(R.string.snackbar_action_text_reconnect_ros),
                        new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                mRunLocalMaster = mSharedPref
                                        .getBoolean(getString(R.string.pref_master_is_local_key), false);
                                mMasterUri = mSharedPref.getString(getString(R.string.pref_master_uri_key),
                                        getResources().getString(R.string.pref_master_uri_default));
                                mUriTextView.setText(mMasterUri);
                                initAndStartRosJavaNode();
                            }
                        });
                View snackBarView = mSnackbarRosReconnection.getView();
                snackBarView.setBackgroundColor(getResources().getColor(android.R.color.holo_red_dark));
                mSnackbarRosReconnection.show();
                // Highlight ROS Master URI.
                AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(RunningActivity.this,
                        R.animator.master_uri_text_animation);
                set.setTarget(mUriTextView);
                set.start();
                // Set settings icon color to red.
                mToolbarMenu.findItem(R.id.settings).setIcon(R.drawable.ic_settings_red_24dp);
            }
        }
    });
}

From source file:com.unipiazza.material2stepslogin.fragments.FirstStepFragment.java

@Nullable
@Override//from  ww w .j  a  v a  2 s . c  om
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.first_login_view, null);

    email = (AutoCompleteTextView) view.findViewById(R.id.email);
    next = (Button) view.findViewById(R.id.buttonNext);
    progressBarFirst = (ProgressBar) view.findViewById(R.id.progressBarFirst);
    layoutFirst = (LinearLayout) view.findViewById(R.id.layoutFirst);
    logo = (ImageView) view.findViewById(R.id.logo);
    descriptionText = (TextView) view.findViewById(R.id.descriptionText);
    registerText = (TextView) view.findViewById(R.id.registerText);
    buttonRegistra = (Button) view.findViewById(R.id.buttonRegistra);

    progressBarFirst.setVisibility(View.GONE);

    if (mtsl != null) {
        view.setBackgroundColor(mtsl.getFirst_step_background_color());
        logo.setImageResource(mtsl.getLogo());
        descriptionText.setText(mtsl.getDescription());

        if (mtsl.getRegister_description() != 0)
            registerText.setText(mtsl.getRegister_description());
        if (mtsl.getRegister_description_text_color() != 0)
            registerText.setTextColor(mtsl.getRegister_description_text_color());

        if (mtsl.getRegister_text() != 0)
            buttonRegistra.setText(mtsl.getRegister_text());
        if (mtsl.getRegister_background() != 0)
            buttonRegistra.setBackgroundResource(mtsl.getRegister_background());
        if (mtsl.getButton_register_text_color() != 0)
            buttonRegistra.setTextColor(mtsl.getButton_register_text_color());

        if (mtsl.getEditText_email_text_color() != 0)
            email.setTextColor(mtsl.getEditText_email_text_color());
        if (mtsl.getEdittext_email_background() != 0)
            email.setBackgroundResource(mtsl.getEdittext_email_background());

        if (mtsl.getButton_next_background() != 0)
            next.setBackgroundResource(mtsl.getButton_next_background());
        if (mtsl.getButton_next_text_color() != 0)
            next.setTextColor(mtsl.getButton_next_text_color());

        if (mtsl.getDescription_text_color() != 0)
            descriptionText.setTextColor(mtsl.getDescription_text_color());

    }

    email.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                next.performClick();
            }
            return false;
        }
    });

    checkAccountPermissions();

    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            progressBarFirst.setVisibility(View.VISIBLE);
            layoutFirst.setVisibility(View.GONE);
            mListener.onNextClicked(email.getText().toString());
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }
    });

    buttonRegistra.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mListener.onRegisterClicked();
        }
    });

    return view;
}

From source file:com.gh4a.IssueLabelListActivity.java

private void unselectLabel(TextView tvLabel, View viewColor, String color) {
    final Typeface condensed = getApplicationContext().condensed;
    tvLabel.setTag(color);/*  w  w  w. j  a  v  a 2  s  .c  o  m*/
    tvLabel.setBackgroundColor(0);
    if (Gh4Application.THEME == R.style.LightTheme) {
        tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light));
    } else {
        tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark));
    }
    tvLabel.setTypeface(condensed);
    viewColor.setBackgroundColor(Color.parseColor("#" + color));
}

From source file:com.pipit.agc.adapter.DayPickerAdapter.java

private String getDayMessage(int dayOfWeek, Date date, View rowview) {
    String primaryText;//from   w w  w. jav  a  2s. c o  m
    SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATE_FORMAT_ONE);
    String datestr = sdf.format(date);
    String gymDay = getContext().getResources().getString(R.string.gym_day);
    String restDay = getContext().getResources().getString(R.string.rest_day);
    if (weeklySchedule.contains(dayOfWeek)) {
        primaryText = gymDay;
    } else {
        primaryText = restDay;
    }

    if (exceptionDays.contains(datestr)) {
        //Flip the day
        if (primaryText.equals(restDay))
            primaryText = gymDay;
        else if (primaryText.equals(gymDay))
            primaryText = restDay;
    }

    if (primaryText.equals(gymDay)) {
        rowview.setBackgroundColor(ContextCompat.getColor(context, R.color.lightgreen));
    } else {
        rowview.setBackgroundColor(ContextCompat.getColor(context, R.color.basewhite));
    }
    return primaryText;
}

From source file:org.lol.reddit.activities.MainActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    OptionsMenuUtility.fixActionBar(this, getString(R.string.app_name));

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPreferences.registerOnSharedPreferenceChangeListener(this);

    final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences)
            && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT;

    super.onCreate(savedInstanceState);

    twoPane = General.isTablet(this, sharedPreferences);

    final View layout;

    if (twoPane)/*from w  w  w  .j a  v  a  2  s  .  c o  m*/
        layout = getLayoutInflater().inflate(R.layout.main_double);
    else
        layout = getLayoutInflater().inflate(R.layout.main_single);

    if (solidblack)
        layout.setBackgroundColor(Color.BLACK);

    setContentView(layout);

    doRefresh(RefreshableFragment.MAIN, false);

    RedditAccountManager.getInstance(this).addUpdateListener(this);

    final PackageInfo pInfo;
    try {
        pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException(e);
    }

    final int appVersion = pInfo.versionCode;

    if (!sharedPreferences.contains("firstRunMessageShown")) {

        new AlertDialog.Builder(this).setTitle(R.string.firstrun_login_title)
                .setMessage(R.string.firstrun_login_message)
                .setPositiveButton(R.string.firstrun_login_button_now, new DialogInterface.OnClickListener() {
                    public void onClick(final DialogInterface dialog, final int which) {
                        new AccountListDialog().show(MainActivity.this);
                    }
                }).setNegativeButton(R.string.firstrun_login_button_later, null).show();

        final SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString("firstRunMessageShown", "true");
        edit.commit();

    } /* else if (sharedPreferences.contains("lastVersion")) {
              
      final int lastVersion = sharedPreferences.getInt("lastVersion", 0);
              
      if (lastVersion != appVersion) {
              
          General.quickToast(this, "Updated to version " + pInfo.versionName);
              
          sharedPreferences.edit().putInt("lastVersion", appVersion).commit();
          ChangelogDialog.newInstance().show(this);
              
          if (lastVersion <= 51) {
              // Upgrading from v1.8.6.3 or lower
              
              final Set<String> existingCommentHeaderItems = PrefsUtility.getStringSet(
                      R.string.pref_appearance_comment_header_items_key,
                      R.array.pref_appearance_comment_header_items_default,
                      this,
                      sharedPreferences
              );
              
              existingCommentHeaderItems.add("gold");
              
              sharedPreferences.edit().putStringSet(
                      R.string.pref_appearance_comment_header_items_key,
                      existingCommentHeaderItems
              ).commit();
              
              new Thread() {
                  @Override
                  public void run() {
                      CacheManager.getInstance(MainActivity.this).emptyTheWholeCache();
                  }
              }.start();
          }
      }
              
      } else {
      sharedPreferences.edit().putInt("lastVersion", appVersion).commit();
      ChangelogDialog.newInstance().show(this);
      }*/

    addSubscriptionListener();

    Boolean startInbox = getIntent().getBooleanExtra("isNewMessage", false);
    if (startInbox) {
        startActivity(new Intent(this, InboxListingActivity.class));
    }
}