Example usage for android.view View setBackgroundDrawable

List of usage examples for android.view View setBackgroundDrawable

Introduction

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

Prototype

@Deprecated
public void setBackgroundDrawable(Drawable background) 

Source Link

Usage

From source file:com.gudong.appkit.ui.fragment.ColorChooseDialog.java

private void setBackgroundCompat(View view, Drawable d) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(d);/*from  ww  w.  j  a v a2 s. co  m*/
    } else {
        //noinspection deprecation
        view.setBackgroundDrawable(d);
    }
}

From source file:com.jameswolfeoliver.pigeon.Utilities.DrawableHelper.java

@SuppressWarnings("deprecation")
public void applyToBackground(@NonNull View view) {
    if (mWrappedDrawable == null) {
        throw new NullPointerException();
    }/*  w  w w. ja v  a2s  .c om*/

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(mWrappedDrawable);
    } else {
        view.setBackgroundDrawable(mWrappedDrawable);
    }
}

From source file:org.kde.kdeconnect.UserInterface.List.SmallEntryItem.java

@Override
public View inflateView(LayoutInflater layoutInflater) {
    View v = layoutInflater.inflate(android.R.layout.simple_list_item_1, null);

    TextView titleView = (TextView) v.findViewById(android.R.id.text1);
    if (titleView != null) {
        titleView.setText(title);//  ww w. ja v a 2  s . c o  m
        if (clickListener != null) {
            titleView.setOnClickListener(clickListener);
            v.setBackgroundDrawable(ContextCompat.getDrawable(layoutInflater.getContext(),
                    R.drawable.abc_list_selector_holo_dark));
        }
    }

    return v;
}

From source file:org.openintents.historify.ui.fragments.MainScreenFragment.java

/** Called to have the fragment instantiate its user interface view. */
@Override/*from  w  w w  .  jav a  2 s .  c om*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.fragment_main_screen, container, false);

    // init list for contacts
    lstContacts = (HorizontalListView) layout.findViewById(R.id.main_screen_lstContacts);
    recentlyContactedAdapter = new RecentlyContactedAdapter(getActivity());
    lstContacts.setAdapter(recentlyContactedAdapter);

    lstContacts.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> adapterView, final View view, int pos, long id) {

            view.setBackgroundResource(R.drawable.bubble);
            view.postDelayed(new Runnable() {
                public void run() {
                    view.setBackgroundDrawable(null);
                }
            }, 500);

            onContactClicked((Contact) adapterView.getItemAtPosition(pos));

        }
    });

    // init list empty view
    View viewContactListEmpty = layout.findViewById(R.id.main_screen_viewEmptyList);
    viewContactListEmpty.setVisibility(View.GONE);
    lstContacts.setEmptyView(viewContactListEmpty);

    // init buttons
    btnMore = (Button) layout.findViewById(R.id.main_screen_btnMore);

    btnFavorites = (Button) layout.findViewById(R.id.main_screen_btnFavorites);
    btnSources = (Button) layout.findViewById(R.id.btnSources);

    if (btnMore != null) {
        btnMore.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                onMoreClicked();
            }
        });

        btnFavorites.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                onFavoritesClicked();
            }
        });

        btnSources.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                onSourcesClicked();
            }
        });
    }

    return layout;
}

From source file:cz.tomas.StockAnalyze.News.NewsListAdapter.java

@Override
public void bindView(View view, Context arg1, Cursor cursor) {
    super.bindView(view, arg1, cursor);
    TextView txtDate = (TextView) view.findViewById(R.id.txtNewsItemBottomInfo);
    View readMark = view.findViewById(R.id.viewReadMark);
    //String desc = cursor.getString(cursor.getColumnIndex(ArticleColumns.DESCRIPTION));
    long date = cursor.getLong(cursor.getColumnIndex(ArticleColumns.DATE));
    boolean read = cursor.getInt(cursor.getColumnIndex(ArticleColumns.READ)) > 0;

    if (read) {/*ww  w  .  j  a  v a2s.c o m*/
        readMark.setBackgroundDrawable(null);
    }
    cal.setTimeInMillis(date);
    String dateText = FormattingUtils.formatDate(cal);
    txtDate.setText(dateText);
}

From source file:org.telegram.ui.ActionBar.ActionBarMenu.java

public View addItemResource(int id, int resourceId) {
    LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = li.inflate(resourceId, null);
    view.setTag(id);//from   www .  j av a  2s .  c om
    addView(view);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) view.getLayoutParams();
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    view.setBackgroundDrawable(Theme.createBarSelectorDrawable(parentActionBar.itemsBackgroundColor));
    view.setLayoutParams(layoutParams);
    view.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            onItemClick((Integer) view.getTag());
        }
    });
    return view;
}

From source file:com.justplay1.shoppist.shared.widget.animboxes.SelectBoxView.java

@SuppressWarnings("deprecation")
private void setDrawable(View view, Integer color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(createShape(color));
    } else {// w w w.j av  a2s .c om
        view.setBackgroundDrawable(createShape(color));
    }
}

From source file:com.igs.qhrzlc.utils.view.astuetz.viewpager.extensions.FixedTabsView.java

/**
 * Creates and returns a new Separator View
 * //from  w  w  w .  j a  va2  s . co m
 * @return
 */
private View getSeparator() {
    View v = new View(mContext);

    LayoutParams params = new LayoutParams(1, LayoutParams.FILL_PARENT);
    params.setMargins(0, mDividerMarginTop, 0, mDividerMarginBottom);
    v.setLayoutParams(params);

    if (mDividerDrawable != null)
        v.setBackgroundDrawable(mDividerDrawable);
    else
        v.setBackgroundColor(mDividerColor);

    return v;
}

From source file:com.artioml.practice.activities.LicenseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_license);
    setActionBar();// ww  w .j  av  a  2 s  .co  m

    Button acceptButton = (Button) findViewById(R.id.acceptButton);

    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(IS_FIRST_TIME, true)) {
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayShowHomeEnabled(false);
            actionBar.setHomeButtonEnabled(false);
            actionBar.setDisplayHomeAsUpEnabled(false);
        }
    }
    if (getSharedPreferences(PERSISTENT_STORAGE, MODE_PRIVATE).getBoolean(IS_ACCEPTED, false)) {
        acceptButton.setVisibility(View.INVISIBLE);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    acceptButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getSharedPreferences(PERSISTENT_STORAGE, MODE_PRIVATE).edit().putBoolean(IS_ACCEPTED, true).apply();
            finish();
        }
    });

    final View line = findViewById(R.id.lineView);
    line.post(new Runnable() {
        @Override
        public void run() {
            BitmapDrawable parallel = drawParallelogramLine(line.getWidth());
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                line.setBackgroundDrawable(parallel);
            } else {
                line.setBackground(parallel);
            }
        }
    });

}

From source file:com.intirix.cloudpasswordmanager.pages.settings.SavePasswordOptionsViewHolder.java

private void addBorder(View view) {
    //use a GradientDrawable with only one color set, to make it a solid color
    GradientDrawable border = new GradientDrawable();
    border.setColor(0xFFFFFFFF); //white background
    border.setStroke(1, 0xFF000000); //black border with full opacity
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackgroundDrawable(border);
    } else {/*w w w  . j  ava 2s  . c  om*/
        view.setBackground(border);
    }
}