Android: where to find RadioButton Drawable?

Ok, I'm trying to create my own view called CheckedRelativeLayout .

The goal is the same as CheckedTextView , to use it in the list of items you want to select, or in Spinner .

Now everything works fine, I expanded RelativeLayout and implemented the Checkable interface.

However, I'm stuck with a pretty simple problem: Where can I find Drawable , what CheckedTextView and RadioButton use?

I looked at the source code of both, and they seem to be using com.android.internal.R . Well ... this is an internal affair. Therefore, I cannot access it.

Any way to get these drawables or solve the problem somehow?

+6
android radio-button drawable
source share
3 answers

look under the folder SDK / platforms / android-2.0 / data / res / you can access them either using android.R.drawable (if available), or if necessary copy them in accordance with your project.

+13
source share

For completeness:

Here are some code snippets that show how I work on the accepted answer.

  //Image Setup (Once when creating this view) ImageView indicator = (ImageView) findViewById(R.id.RadioStatusImage); indicator.setImageDrawable(getResources().getDrawable(android.R.drawable.btn_radio)); //State Change (In some other method) android.R.attr.state_checked if (isChecked) { indicator.setImageState(android.R.attr.state_checked, false); } else { indicator.setImageState(View.ENABLED_STATE_SET, false); } invalidate(); 
+5
source share

To use the new animated default toggle button, the correct answer is in the @sidon comment:

?android:attr/listChoiceIndicatorSingle

Using this in a user position relative to the text:

 <RadioButton ... android:gravity="center_horizontal|bottom" android:drawableTop="?android:attr/listChoiceIndicatorSingle" android:button="@null" /> 
0
source share

All Articles