android,android-fragments,android-radiogroup,android-radiobutton
you can get it like this int radioButtonID = group.getCheckedRadioButtonId(); View radioButton = group.findViewById(radioButtonID); // If you want position of Radiobutton int position = group.indexOfChild(radioButton); Complete code //complete code.. //rgp is your radio group rgp.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int radioButtonID = group.getCheckedRadioButtonId(); View...
android,android-layout,android-radiobutton
Try using the layout_margin attribute, it works similarly to padding, but may have the effect you want. You can use simply android:layout_margin="20dp" or you can set individual sides, like you can for padding (ex: android:layout_marginLeft="20dp").
android,android-layout,android-radiobutton
You can try using FlowLayout which automatically arranges View when it runs out of space.
android-layout,android-arrayadapter,android-radiobutton
Finally after some hacks i solved it! i removed all the radio buttons in the else clause. The solution.. public class QuestionsListAdapter extends ArrayAdapter<QuestionProperties> { List<QuestionProperties> list; RadioButton rB; Context test; RadioHolder holder; String chkBtn; LinearLayout.LayoutParams layoutParams = new RadioGroup.LayoutParams( RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT); public QuestionsListAdapter(Context context, int resource, List<QuestionProperties> list2) {...
java,android,sharedpreferences,android-alertdialog,android-radiobutton
Do this in onCreate: SharedPreferences preferences = getSharedPreferences("myPref", getApplicationContext().MODE_PRIVATE); index = preferences.getInt("choice",-1); if (index == 1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getWindow().setStatusBarColor(MainActivity.this.getResources().getColor(R.color.redDark)); toolbar.setBackgroundColor(MainActivity.this.getResources().getColor(R.color.red));...
android,onclicklistener,android-button,android-radiobutton,oncheckedchanged
The RadioGroup example shouldn't even run, because the rg variable is never assigned and thus creates a NullPointerException when you try to set the onCheckedChanged listener. Essentially there should be no differences with the usage of the Button and RadioGroup classes, at least in this regard. This is more a...
android-linearlayout,android-drawable,xml-drawable,android-radiogroup,android-radiobutton
Yes, you can add some padding, which will result in som inner space added: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <padding android:left="4dp" android:top="4dp" android:right="4dp" android:bottom="4dp" /> <stroke android:width="1dp" android:color="#f000" /> </shape> Feel free to experiment different values other than 4dp (even different for top/bottom, left/right sides)...
android,android-layout,android-radiobutton
Ok, lets see if it works: Spannable span = new SpannableStringBuilder(rb.getText().toString()); span.setSpan(new BackgroundColorSpan(Color.RED), 0, rb.getText().toString().length(), SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE); rb.setText(span); Replace Color.RED with whichever color you want. Don't forget you have to grab it from the resources if you want it. I don't think it works with drawables....
android,android-radiogroup,android-radiobutton
use this for(int i =0; i<ab.length;i++) { RadioButton radioButtonView = new RadioButton(this); radioButtonView.setText(ab[i]); radioButtonView.setTextColor(R.color.color_name); radioButtonView.setBackGroundResource(R.drawable.rbtn_selector); radioGroup.addView(radioButtonView, p); } ...
there are few ways to do it, you can try this <RadioGroup android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginLeft="-10dp" > ... android:layout_marginLeft="-10dp" does it do what you need ?...
You can use setCompoundDrawablesWithIntrinsicBounds, since RadioButton is a subclass of TextView. E.g. radioButton.setCompoundDrawablesWithIntrinsicBounds (0, R.drawable.your_drawable_selector, 0, 0). If you have a Bitmap you can use Drawable drawable = new BitmapDrawable(getResources(), yourBitmap); radioButton.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); From the documentation Sets the Drawables (if any) to appear to the left of, above,...
Try uans.setChecked(false); - from your code this is getting the checked radio button from the group (rg1). Tip: If you need to change the radio button state yourself (such as when loading a saved CheckBoxPreference), use the setChecked(boolean) or toggle() method....
android,android-resources,android-drawable,android-radiobutton
You have to set your radiobutton's background from Java code: radioButton.setButtonDrawable(R.drawable.custom_radiogroup_divider); It works with checkbox too ;)...
android,android-radiogroup,android-radiobutton
Previous answers contains some issue. The dots to selected are not in one column, they are not aligned. This is solution which looks the same like your. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <RadioGroup android:layout_width=" wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:orientation="vertical"> <RadioButton android:id="@+id/rbtn_gps_to"...
android,android-radiogroup,android-radiobutton
Hide RadioButton indicator with: android:button="@null" xml attribute to RadioButton item. Then create your own selector like this: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/..."/> <item android:state_focused="true" android:drawable="@drawable/..."/> <item android:state_checked="true" android:drawable="@drawable/..."/> <item android:drawable="@android:color/transparent"/> </selector> if you want change...
android,radio-button,eclipse-adt,android-radiogroup,android-radiobutton
do like this for your all RadioGroup rg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub int childCount=group.getChildCount(); for (int i=0;i<childCount;i++){ RadioButton r_btn = (RadioButton) group.getChildAt(i); if (r_btn.getId() == checkedId) { // do your stuf here sum1=i+1; // since position is from 0....
android,nullpointerexception,sharedpreferences,android-radiogroup,android-radiobutton
As you have implemented an onCheckedChangeListener event which is always gets called automatically whenever your activity starts. So the problem occurs is though your sharedpreference value is correct you are getting but after that immediately your CheckedChangeListener is called so the value which you have from your preference gets reset...
android,arrays,android-radiobutton
Use RadioGroup.removeViewAt(int index) or RadioGroup.removeView(View view) or RadioGroup.removeViews(int start, int count)