简体   繁体   中英

Android setTextViewCompoundDrawables for API 14

I'm using setTextViewCompoundDrawables to set the compound drawables of a TextView inside a homescreen widget. However, I'm targeting API levels 14+, so I cannot use this method.

This is what I'm using at the moment:

cellRv.setTextViewCompoundDrawables(android.R.id.text1, 0, 0, 0, R.drawable.indicator);

I need to set the drawables programatically rather than from inside the XML layout I'm using, since I'm pulling data from a database to populate the widget.

Are there any alternate solutions to this?

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
  cellRv.setTextViewCompoundDrawables(android.R.id.text1, 0, 0, 0, R.drawable.indicator);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM