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.deviceconnect.android.uiapp.fragment.profile.PhoneProfileFragment.java

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

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

    final TextView num = (TextView) view.findViewById(R.id.fragment_phone_number);

    final OnClickListener l = new OnClickListener() {
        @Override/*from   ww  w .jav  a2s  .  com*/
        public void onClick(final View v) {
            String phone = num.getText().toString();
            int id = v.getId();
            if (id == R.id.fragment_phone_1) {
                phone += "1";
            } else if (id == R.id.fragment_phone_2) {
                phone += "2";
            } else if (id == R.id.fragment_phone_3) {
                phone += "3";
            } else if (id == R.id.fragment_phone_4) {
                phone += "4";
            } else if (id == R.id.fragment_phone_5) {
                phone += "5";
            } else if (id == R.id.fragment_phone_6) {
                phone += "6";
            } else if (id == R.id.fragment_phone_7) {
                phone += "7";
            } else if (id == R.id.fragment_phone_8) {
                phone += "8";
            } else if (id == R.id.fragment_phone_9) {
                phone += "9";
            } else if (id == R.id.fragment_phone_a) {
                phone += "*";
            } else if (id == R.id.fragment_phone_0) {
                phone += "0";
            } else if (id == R.id.fragment_phone_s) {
                phone += "#";
            } else if (id == R.id.fragment_phone_clear) {
                phone = "";
            }
            num.setText(phone);
        }
    };

    int[] ids = { R.id.fragment_phone_1, R.id.fragment_phone_2, R.id.fragment_phone_3, R.id.fragment_phone_4,
            R.id.fragment_phone_5, R.id.fragment_phone_6, R.id.fragment_phone_7, R.id.fragment_phone_8,
            R.id.fragment_phone_9, R.id.fragment_phone_a, R.id.fragment_phone_0, R.id.fragment_phone_s,
            R.id.fragment_phone_clear };

    for (int i = 0; i < ids.length; i++) {
        Button btn = (Button) view.findViewById(ids[i]);
        btn.setOnClickListener(l);
    }

    Button send = (Button) view.findViewById(R.id.fragment_phone_send);
    send.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            callPhone(num.getText().toString());
        }
    });
    return view;
}

From source file:com.rjones.languagedictionary.WordAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    //Check if the existing view is being reused, otherwise inflate the view
    View listItemView = convertView;
    if (listItemView == null) {
        listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false);
    }//  ww  w .j  av a  2s  . c om

    //Get the {@link WordAdapter} object located at this position in the list
    Word currentWord = getItem(position);

    //Find the TextView in the list_item.xml layout the ID foreign_text_view
    TextView foreignTextView = (TextView) listItemView.findViewById(R.id.foreign_text_view);
    //Get the Foreign translation from the current Word object and set this text on the foreignLang
    foreignTextView.setText(currentWord.getForeignLang());

    //Find the TextView in the list_item.xml layout the ID foreign_text_view
    TextView nativeTextView = (TextView) listItemView.findViewById(R.id.native_text_view);
    //Get the Foreign translation from the current Word object and set this text on the nativeLang
    nativeTextView.setText(currentWord.getNativeLang());

    //Set the theme color for the list item
    View textContainer = listItemView.findViewById(R.id.text_container);
    //Find the color that resource ID maps too
    int color = ContextCompat.getColor(getContext(), mColorResourceId);
    textContainer.setBackgroundColor(color);

    return listItemView;
}

From source file:mobisocial.musubi.ui.AcceptFriendActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDatabaseSource = App.getDatabaseSource(this);
    mIdentitiesManager = new IdentitiesManager(mDatabaseSource);

    View view = new View(this);
    view.setBackgroundColor(Color.TRANSPARENT);
    setContentView(view);//  w  w  w .ja v a 2s. com

}

From source file:org.addhen.smssync.presentation.view.ui.fragment.BasePreferenceFragmentCompat.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Set the default white background in the view so as to avoid transparency
    view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.background_material_light));

}

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

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

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

    final String[] methods = { "GET", "POST", "PUT", "DELETE" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item);
    for (int i = 0; i < methods.length; i++) {
        adapter.add(methods[i]);//  www  .j  a  v  a 2 s. c  o  m
    }
    Spinner spinner = (Spinner) view.findViewById(R.id.spinner);
    spinner.setAdapter(adapter);

    Button sendButton = (Button) view.findViewById(R.id.fragment_extra_send);
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View view) {
            onClickSend(view);
        }
    });

    return view;
}

From source file:com.example.anandchandrasekar.wardrobeadvisor.FilterKindFragment.java

public void updateSelectedFilters() {
    selectedFiltersList = filterSelectedListener.getCurrentlySelectedFilters();

    Iterator it = filterViewMap.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pair = (Map.Entry) it.next();
        ItemFilter currFilter = (ItemFilter) pair.getKey();
        View currFilterView = (View) pair.getValue();

        if (selectedFiltersList.contains(currFilter)) {
            currFilterView.setBackgroundColor(Color.parseColor("#FF9191"));//D91C2F
        } else {/*from  w w  w  . j  a v  a  2  s.c  o m*/
            currFilterView.setBackgroundColor(Color.TRANSPARENT);
        }
    }
}

From source file:com.justwayward.reader.view.recyclerview.adapter.BaseViewHolder.java

public BaseViewHolder setBackgroundColor(int viewId, int color) {
    View view = getView(viewId);
    view.setBackgroundColor(color);
    return this;
}

From source file:com.android.calculator2.StoreActivity.java

@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private void setBackground(View v, Res res) {
    if (res != null) {
        if (Theme.COLOR.equals(res.getType())) {
            v.setBackgroundColor(Theme.getColor(getContext(), res.getName()));
        } else if (Theme.DRAWABLE.equals(res.getType())) {
            if (android.os.Build.VERSION.SDK_INT < 16) {
                v.setBackgroundDrawable(Theme.getDrawable(getContext(), res.getName()));
            } else {
                v.setBackground(Theme.getDrawable(getContext(), res.getName()));
            }//  w w  w  .  j  a va2 s.  c  o  m
        }
    }
}

From source file:com.odoo.base.login_signup.SyncWizard.java

private void generateLayout() {

    LinearLayout layout = (LinearLayout) rootView.findViewById(R.id.layoutLoginConfig);
    SyncWizardValues syncValues = new SyncWizardValues();
    List<SyncValue> syncValuesList = syncValues.syncValues();
    if (syncValuesList.size() == 0) {
        getActivity().finish();/* w  w w  .j a v  a 2s  .c  o m*/
        getActivity().startActivity(getActivity().getIntent());
    }
    checkbox = new CheckBox[syncValuesList.size()];
    rdoGroups = new RadioGroup[syncValuesList.size()];
    TextView[] txvTitles = new TextView[syncValuesList.size()];
    int i = 0;
    int id = 1;
    Typeface tf_light = Typeface.create("sans-serif-light", 0);
    Typeface tf_bold = Typeface.create("sans-serif-condensed", 0);
    for (SyncValue value : syncValuesList) {
        if (!value.getIsGroup()) {
            if (value.getType() == SyncValue.Type.CHECKBOX) {
                checkbox[i] = new CheckBox(scope.context());
                checkbox[i].setId(id);
                checkbox[i].setText(value.getTitle());
                checkbox[i].setTypeface(tf_light);
                layout.addView(checkbox[i]);
            } else {
                rdoGroups[i] = new RadioGroup(scope.context());
                rdoGroups[i].setId(i + 50);
                RadioButton[] rdoButtons = new RadioButton[value.getRadioGroups().size()];
                int mId = 1;
                int j = 0;
                for (SyncValue rdoVal : value.getRadioGroups()) {
                    rdoButtons[j] = new RadioButton(scope.context());
                    rdoButtons[j].setId(mId);
                    rdoButtons[j].setText(rdoVal.getTitle());
                    rdoButtons[j].setTypeface(tf_light);
                    rdoGroups[i].addView(rdoButtons[j]);
                    mId++;
                    j++;
                }
                layout.addView(rdoGroups[i]);
            }
            authorities.put(id + "", value.getAuthority());
            i++;
            id++;
        } else {
            txvTitles[i] = new TextView(scope.context());
            txvTitles[i].setId(id);
            txvTitles[i].setText(value.getTitle());
            txvTitles[i].setAllCaps(true);
            txvTitles[i].setPadding(0, 5, 0, 3);
            txvTitles[i].setTypeface(tf_bold);
            layout.addView(txvTitles[i]);
            View lineView = new View(scope.context());
            lineView.setBackgroundColor(Color.parseColor("#BEBEBE"));
            lineView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1));
            layout.addView(lineView);
        }
    }
}

From source file:org.liberty.android.fantastischmemo.ui.TwoFieldsCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.two_fields_card_layout, container, false);
    field1CardPager = (ViewPager) v.findViewById(R.id.field1);
    field1CardPager.setAdapter(new FragmentStatePagerAdapter(getChildFragmentManager()) {

        @Override/*  www. j  a  va2s . c o m*/
        public Fragment getItem(int position) {
            return field1CardFragmentBuilders[position].build();
        }

        @Override
        public int getCount() {
            return field1CardFragmentBuilders.length;
        }
    });
    field2CardPager = (ViewPager) v.findViewById(R.id.field2);
    field2CardPager.setAdapter(new FragmentStatePagerAdapter(getChildFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            return field2CardFragmentBuilders[position].build();
        }

        @Override
        public int getCount() {
            return field2CardFragmentBuilders.length;
        }
    });

    // Handle the QA ratio
    float qRatio = qaRatio;
    if (qRatio > 99.0f) {
        field2CardPager.setVisibility(View.GONE);
        field1CardPager
                .setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
        field2CardPager
                .setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    } else if (qRatio < 1.0f) {
        field1CardPager.setVisibility(View.GONE);
        field1CardPager
                .setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
        field2CardPager
                .setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    } else {
        field1CardPager.setLayoutParams(
                new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, qRatio));
        field2CardPager.setLayoutParams(
                new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 100f - qRatio));
    }

    // Separator color
    View separatorLine = v.findViewById(R.id.horizontal_line);
    separatorLine.setBackgroundColor(separatorColor);

    field1CardPager.setCurrentItem(field1InitialPosition);
    field2CardPager.setCurrentItem(field2InitialPosition);

    return v;
}