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:com.google.reviewit.AbandonFragment.java

private void init(final Change change) {
    ((ExpandableCommitMessageView) v(R.id.commitMessage)).init(change);

    v(R.id.abandonButton).setOnClickListener(new View.OnClickListener() {
        @Override/*from w ww  .  ja v a2s  .co  m*/
        public void onClick(final View v) {
            v.setEnabled(false);
            v.setBackgroundColor(widgetUtil.color(R.color.buttonDisabled));
            new AsyncTask<Change, Void, String>() {
                @Override
                protected String doInBackground(Change... changes) {
                    Change change = changes[0];
                    try {
                        change.abandon(textOf(R.id.abandonMessageInput).trim());
                        return null;
                    } catch (RestApiException e) {
                        if (e instanceof HttpStatusException) {
                            HttpStatusException se = (HttpStatusException) e;
                            return getString(R.string.abandon_error, se.getStatusCode(), se.getStatusText());
                        } else {
                            return e.getMessage();
                        }
                    }
                }

                protected void onPostExecute(String errorMsg) {
                    if (errorMsg != null) {
                        v.setEnabled(true);
                        v.setBackgroundColor(widgetUtil.color(R.color.button));
                        widgetUtil.showError(errorMsg);
                    } else {
                        widgetUtil.toast(R.string.change_abandoned);
                        display(SortChangesFragment.class);
                    }
                }
            }.execute(change);
        }
    });
}

From source file:com.google.reviewit.RestoreFragment.java

private void init(final Change change) {
    ((ExpandableCommitMessageView) v(R.id.commitMessage)).init(change);

    v(R.id.restoreButton).setOnClickListener(new View.OnClickListener() {
        @Override//from   ww  w . j a v a 2 s  .c o m
        public void onClick(final View v) {
            v.setEnabled(false);
            v.setBackgroundColor(widgetUtil.color(R.color.buttonDisabled));
            new AsyncTask<Change, Void, String>() {
                @Override
                protected String doInBackground(Change... changes) {
                    Change change = changes[0];
                    try {
                        change.restore(textOf(R.id.restoreMessageInput).trim());
                        return null;
                    } catch (RestApiException e) {
                        if (e instanceof HttpStatusException) {
                            HttpStatusException se = (HttpStatusException) e;
                            return getString(R.string.restore_error, se.getStatusCode(), se.getStatusText());
                        } else {
                            return e.getMessage();
                        }
                    }
                }

                protected void onPostExecute(String errorMsg) {
                    if (errorMsg != null) {
                        v.setEnabled(true);
                        v.setBackgroundColor(widgetUtil.color(R.color.button));
                        widgetUtil.showError(errorMsg);
                    } else {
                        widgetUtil.toast(R.string.change_restored);
                        display(SortChangesFragment.class);
                    }
                }
            }.execute(change);
        }
    });
}

From source file:org.deviceconnect.android.uiapp.fragment.profile.VibrationProfileFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    View view = inflater.inflate(R.layout.fragment_vibration_service, container, false);
    view.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    final TextView pattern = (TextView) view.findViewById(R.id.fragment_vibration_pattern);

    Button btn = (Button) view.findViewById(R.id.fragment_vibration_send);
    btn.setOnClickListener(new OnClickListener() {
        @Override//from   w w  w .j  av a  2  s  . c  o m
        public void onClick(final View v) {
            sendVibration(pattern.getText());
        }
    });
    return view;
}

From source file:com.desno365.mods.DesnoUtils.java

public static Snackbar getDefaultSnackbar(View parent, int text, int duration) {
    Snackbar snack = Snackbar.make(parent, text, duration);

    // make text white
    View view = snack.getView();
    @SuppressLint("PrivateResource")
    TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
    tv.setTextColor(Color.WHITE);

    // set background and action colors
    TypedArray a = parent.getContext().getTheme()
            .obtainStyledAttributes(new int[] { R.attr.color_primary_dark, R.attr.color_accent });
    int color1 = a.getColor(0, 0);
    int color2 = a.getColor(1, 0);
    a.recycle();//  ww  w.j  a  v  a 2 s.c  om
    view.setBackgroundColor(color1);
    snack.setActionTextColor(color2);

    return snack;
}

From source file:org.androidsoft.games.utils.level.LevelFragment.java

/**
 * The Fragment's UI is just a simple text view showing its instance number.
 *//*from  w w  w .  j  a v  a2  s. co m*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.grid, container, false);
    v.setBackgroundColor(mGraphics.getLightColors(mNum));
    View tv = v.findViewById(R.id.text);
    tv.setBackgroundColor(mGraphics.getDarkColors(mNum));
    ((TextView) tv).setText(mGraphics.getGridTitle(mNum));
    mGridView = (GridView) v.findViewById(R.id.level_grid1);
    mGridView.setAdapter((ListAdapter) new LevelAdapter(mContext, mLevels.get(mNum), mGraphics));
    mGridView.setOnItemClickListener(new LevelClickListener(mContext, mLevels.get(mNum), mListener));

    //Bind the title indicator to the adapter
    mCircleIndicator = (CirclePageIndicator) v.findViewById(R.id.circles);
    mCircleIndicator.setViewPager(mPager);

    final float density = getResources().getDisplayMetrics().density;
    mCircleIndicator.setBackgroundColor(mGraphics.getDarkColors(mNum));
    mCircleIndicator.setRadius(8 * density);
    mCircleIndicator.setPageColor(mGraphics.getLightColors(mNum));
    mCircleIndicator.setFillColor(0xFFFFFFFF);
    mCircleIndicator.setStrokeColor(0xFFFFFFFF);
    mCircleIndicator.setStrokeWidth(1 * density);

    return v;
}

From source file:org.chromium.latency.walt.SettingsFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.ColorBackground));
}

From source file:org.alfresco.mobile.android.application.fragments.node.versions.VersionFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);
    v.setBackgroundColor(getResources().getColor(R.color.secondary_background));
    return v;/*from   w w w  . j a va2 s.  c o m*/
}

From source file:com.albertcbraun.cms50fw.alert.DeactivateAlertTask.java

@Override
public void run() {
    android.support.v4.app.FragmentActivity activity = mainUIFragment.getActivity();
    if (mainUIFragment.uiAlertSet) {
        mainUIFragment.uiAlertSet = false;
        View underlyingView = activity.getWindow().getDecorView().findViewById(android.R.id.content);
        underlyingView.clearAnimation();
        underlyingView.setBackgroundColor(activity.getResources().getColor(android.R.color.white));
        android.support.v4.app.FragmentManager fragmentManager = activity.getSupportFragmentManager();
        UIAlertDialog uiAlertDialog = (UIAlertDialog) fragmentManager.findFragmentByTag(UIAlertDialog.TAG);
        if (uiAlertDialog != null) {
            uiAlertDialog.dismissAllowingStateLoss();
        }/*w  w  w. jav  a2s . c o  m*/
        mainUIFragment.stopAlertSound();
        mainUIFragment.enableAlertSound();
    }
}

From source file:com.teclib.flyvemdm.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        setContentView(R.layout.activity_main_portrait);
        FlyveLog.d("PORTRAIT");
    } else {/*  w  ww.  j a v a 2 s .c  o  m*/
        setContentView(R.layout.activity_main_paysage);
        FlyveLog.d("PAYSAGE");
    }

    View someView = findViewById(R.id.view);
    View root = someView.getRootView();
    root.setBackgroundColor(getResources().getColor(R.color.status_text));

    Intent inventoryService = new Intent(this.getBaseContext(), Agent.class);
    this.getBaseContext().startService(inventoryService);

    Intent monServiceIntent = new Intent(this.getBaseContext(), BootService.class);
    this.getBaseContext().startService(monServiceIntent);
}

From source file:com.github.piasy.chatrecyclerview.example.InputDialogFragment.java

@Override
public void onStart() {
    super.onStart();
    Window window = getDialog().getWindow();
    window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    window.setBackgroundDrawableResource(android.R.color.transparent);

    final Resources res = getResources();
    final int titleDividerId = res.getIdentifier("titleDivider", "id", "android");
    if (titleDividerId > 0) {
        final View titleDivider = getDialog().findViewById(titleDividerId);
        if (titleDivider != null) {
            titleDivider.setBackgroundColor(res.getColor(android.R.color.transparent));
        }//w  ww.  j  ava  2  s. c  o m
    }
}