So the list_selector_drawable is a stateful drawable, where it's default state is black. (This is why ListView unselected items are transparent/black.) The default button drawable is also stateful, but it's default state is an unpressed button.
You could force it into a focused state using Drawable.setState() before setting it to the background. However, keep in mind that you probably don't want to have the TextView always appear selected, as it might confuse users to see two selected areas on screen at once. You might instead try setting the TextView to be focusable, so the background changes automatically whenever the user moves focus to the TextView. j On Wed, May 6, 2009 at 5:57 AM, gsmd <[email protected]> wrote: > > Ok, here's a simple 'helloorange' activity: > -- > �...@override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > TextView tv = new TextView(this); > tv.setText("some text"); > tv.setBackgroundDrawable(getResources().getDrawable > (android.R.drawable.list_selector_background)); > setContentView(tv); > } > -- > When running this, the background doesn't change it's color. When I > change to android.R.drawable.btn_default, it works. > So, how do I apply orange background drawable to a TextView at > runtime? > > TIA. > > > -- Jeff Sharkey [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

