use of android.widget.RadioButton in project PhoneProfilesPlus by henrichg.
the class ConnectToSSIDPreferenceAdapter method getView.
public View getView(final int position, View convertView, ViewGroup parent) {
// SSID to display
WifiSSIDData wifiSSID = preference.ssidList.get(position);
// System.out.println(String.valueOf(position));
ViewHolder holder;
View vi = convertView;
if (convertView == null) {
vi = inflater.inflate(R.layout.connect_to_ssid_preference_list_item, parent, false);
holder = new ViewHolder();
holder.SSIDName = vi.findViewById(R.id.connect_to_ssid_pref_dlg_item_label);
holder.radioButton = vi.findViewById(R.id.connect_to_ssid_pref_dlg_item_radiobutton);
vi.setTag(holder);
} else {
holder = (ViewHolder) vi.getTag();
}
if (wifiSSID.ssid.equals(Profile.CONNECTTOSSID_JUSTANY))
holder.SSIDName.setText(R.string.connect_to_ssid_pref_dlg_summary_text_just_any);
else if (wifiSSID.ssid.equals(Profile.CONNECTTOSSID_DEFAULTPROFILE))
holder.SSIDName.setText(R.string.array_pref_default_profile);
else
holder.SSIDName.setText(wifiSSID.ssid);
holder.radioButton.setTag(position);
holder.radioButton.setChecked(preference.value.equals(wifiSSID.ssid));
holder.radioButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
RadioButton rb = (RadioButton) v;
preference.value = preference.ssidList.get((Integer) rb.getTag()).ssid;
notifyDataSetChanged();
}
});
return vi;
}
use of android.widget.RadioButton in project Quizly by sebastianjs12.
the class StudentQuestionTemp method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.student_question_temp);
// Selects radioGroup on layout
radioGroup = findViewById(R.id.radioGroup);
Button nextQuestion = findViewById(R.id.nextQuestion);
TextView questionText = (TextView) findViewById(R.id.questionText);
questionText.setText("How many moons are in our Solar System?");
nextQuestion.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Returns the value of the checked radio button
int radioId = radioGroup.getCheckedRadioButtonId();
if (radioId == -1) {
// No selection, prompts user for input
Toast temp3 = Toast.makeText(getApplicationContext(), "Please select an answer choice", Toast.LENGTH_SHORT);
temp3.show();
} else if (radioId == 2131165194) {
// Answer choice A is selected (2131165194)
System.out.println("Selected answer choice A");
// Finds the radio button that was selected
radioButton = findViewById(radioId);
// Stores selected answer in ArrayList
studentAnswers.add((String) radioButton.getText());
// Outputs choice to console
System.out.println(radioButton.getText());
// Goes to next question
Intent i = new Intent(StudentQuestionTemp.this, StudentQuestionTemp.class);
startActivity(i);
} else if (radioId == 2131165230) {
// Answer choice B is selected (2131165230)
System.out.println("Selected answer choice B");
radioButton = findViewById(radioId);
studentAnswers.add((String) radioButton.getText());
// Outputs choice to console
System.out.println(radioButton.getText());
Intent i = new Intent(StudentQuestionTemp.this, StudentQuestionTemp.class);
startActivity(i);
} else if (radioId == 2131165236) {
// Answer choice C is selected (2131165236)
System.out.println("Selected answer choice C");
radioButton = findViewById(radioId);
studentAnswers.add((String) radioButton.getText());
// Outputs choice to console
System.out.println(radioButton.getText());
Intent i = new Intent(StudentQuestionTemp.this, StudentQuestionTemp.class);
startActivity(i);
} else {
// Answer choice D is selected (2131165248)
System.out.println("Selected answer choice D");
radioButton = findViewById(radioId);
studentAnswers.add((String) radioButton.getText());
// Outputs choice to console
System.out.println(radioButton.getText());
Intent i = new Intent(StudentQuestionTemp.this, StudentQuestionTemp.class);
startActivity(i);
}
}
});
}
use of android.widget.RadioButton in project Roblu by wdavies973.
the class RMetricToUI method getBoolean.
/**
* Gets the Boolean UI card from an RBoolean reference
* @param bool RBoolean reference to be set to the UI
* @return a UI CardView
*/
public CardView getBoolean(final RBoolean bool) {
RadioGroup group = new RadioGroup(activity);
AppCompatRadioButton yes = new AppCompatRadioButton(activity);
AppCompatRadioButton no = new AppCompatRadioButton(activity);
yes.setEnabled(editable);
no.setEnabled(editable);
ColorStateList colorStateList = new ColorStateList(new int[][] { // unchecked
new int[] { -android.R.attr.state_checked }, // checked
new int[] { android.R.attr.state_checked } }, new int[] { rui.getButtons(), rui.getAccent() });
CompoundButtonCompat.setButtonTintList(yes, colorStateList);
CompoundButtonCompat.setButtonTintList(no, colorStateList);
group.setId(Utils.generateViewId());
yes.setId(Utils.generateViewId());
no.setId(Utils.generateViewId());
yes.setTextColor(rui.getText());
no.setTextColor(rui.getText());
yes.setText(R.string.yes);
no.setText(R.string.no);
final RelativeLayout layout = new RelativeLayout(activity);
final TextView observed = new TextView(activity);
// don't check either if the boolean isn't modified
yes.setChecked(bool.isValue());
yes.setHighlightColor(rui.getAccent());
no.setChecked(!bool.isValue());
no.setPadding(0, 0, 0, Utils.DPToPX(activity, 10));
no.setHighlightColor(rui.getAccent());
group.addView(yes);
group.addView(no);
no.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
layout.removeView(observed);
listener.changeMade(bool);
}
});
yes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
layout.removeView(observed);
listener.changeMade(bool);
}
});
// Observed field
observed.setTextColor(rui.getText());
observed.setText(R.string.not_observed_yet);
observed.setTextSize(10);
observed.setPadding(observed.getPaddingLeft(), Utils.DPToPX(activity, 15), observed.getPaddingRight(), observed.getPaddingBottom());
observed.setId(Utils.generateViewId());
observed.setTag("N.O.");
observed.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!editable)
return;
layout.removeView(observed);
listener.changeMade(bool);
}
});
group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
layout.removeView(observed);
bool.setValue(((RadioButton) radioGroup.getChildAt(0)).isChecked());
listener.changeMade(bool);
}
});
TextView title = new TextView(activity);
title.setTextColor(rui.getText());
title.setText(bool.getTitle());
title.setMaxWidth(width);
title.setTextSize(20);
title.setId(Utils.generateViewId());
// observed params
RelativeLayout.LayoutParams oParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
oParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
oParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
oParams.addRule(RelativeLayout.BELOW, group.getId());
observed.setLayoutParams(oParams);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
group.setLayoutParams(params);
group.setPadding(group.getPaddingLeft(), group.getPaddingTop(), Utils.DPToPX(activity, 10), group.getPaddingBottom());
params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
title.setPadding(Utils.DPToPX(activity, 4), title.getPaddingTop(), title.getPaddingRight(), title.getPaddingBottom());
title.setLayoutParams(params);
layout.addView(title);
layout.addView(group);
if (!bool.isModified())
layout.addView(observed);
return getCard(layout);
}
use of android.widget.RadioButton in project packages_apps_Contacts by AOKP.
the class ConfirmReplaceDetailActivity method doReplaceAction.
private void doReplaceAction() {
String oldNumber = null;
if (mList.size() == 1) {
oldNumber = mList.get(0);
} else {
int radioButtonId = radioGroup.getCheckedRadioButtonId();
oldNumber = ((RadioButton) findViewById(radioButtonId)).getText().toString();
}
int position = mList.indexOf(oldNumber);
ValuesDelta valuesDelta = mRawContactDelta.getMimeEntries(mMimeType).get(position);
String newNumber = null;
if (mMimeType.equals(Phone.CONTENT_ITEM_TYPE)) {
newNumber = extras.getString(Insert.PHONE);
valuesDelta.getAfter().put(Phone.NUMBER, newNumber);
} else {
newNumber = extras.getString(Insert.EMAIL);
valuesDelta.getAfter().put(Email.ADDRESS, newNumber);
}
Intent intent = new Intent();
intent.putExtra(ConfirmAddDetailActivity.RAWCONTACTS_DELTA_LIST, (Parcelable) mEntityDeltaList);
setResult(RESULT_OK, intent);
finish();
}
use of android.widget.RadioButton in project GogoNew by kuldeep725.
the class MapsActivity method onStart.
@Override
public void onStart() {
super.onStart();
Log.d(TAG, "onStart fired ..............");
if (!checkPermissions()) {
requestPermissions();
}
FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser == null) {
Intent i = new Intent(MapsActivity.this, Login.class);
startActivity(i);
finish();
}
showInternetStatus();
SharedPreferences loginPrefs = getSharedPreferences("userId", MODE_PRIVATE);
userEmail = loginPrefs.getString("email", "User id");
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View headerView = navigationView.getHeaderView(0);
TextView tv = (TextView) headerView.findViewById(R.id.user_id);
tv.setText(userEmail);
SharedPreferences prefs = getSharedPreferences("onStop", MODE_PRIVATE);
// boolean floatingClickable = prefs.getBoolean(floatingClickableState, Boolean.TRUE);
radiobuttonId = prefs.getInt(radioButtonString, 0);
flagSendOrCancel = prefs.getInt("flagSendOrCancel", 0);
int bus = prefs.getInt(whichBus, 0);
theKey = prefs.getString(keyString, null);
pickMeRadioButtonId = prefs.getInt("pickMeRadioButton", -1);
minName = prefs.getString(minNameStr, null);
Log.e(TAG, "onStart-> pickMeRadioButtonId = " + pickMeRadioButtonId);
Log.d(TAG, "flagSendOrCancel" + " = " + flagSendOrCancel);
Log.d(TAG, "radiobuttonId" + " = " + radiobuttonId);
Log.d(TAG, whichBus + " = " + bus);
Log.d(TAG, "theKey = " + theKey);
Log.d(TAG, "minName = " + minName);
checkBusSelection = radiobuttonId;
BUS = prefs.getString("pickMeBus", null);
if (BUS == null) {
BUS = "b" + checkBusSelection;
}
if (flagSendOrCancel != 0) {
floatingButton.setImageResource(R.drawable.ic_cancel_white_24dp);
floatingButton.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.myRed)));
pickMeDone = true;
}
if (checkPermissions()) {
mGoogleApiClient.connect();
Log.e(TAG, "mGoogleApiClient is connected");
} else {
Log.e(TAG, "mGoogleApiClient is not connected");
}
mDatabase.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Log.d(TAG, "dataSnapshot.getKey() = " + dataSnapshot.getKey());
Log.d(TAG, "dataSnapshot.getChildrenCount() = " + dataSnapshot.getChildrenCount());
/*check whether onChildAdded has already run once**/
if (flagOnChild == 1)
return;
noOfBuses = dataSnapshot.getChildrenCount();
Log.d(TAG, "noOfBuses = " + noOfBuses);
// Log.d(TAG, "String s = " + s);
createRadioButtons();
if (radiobuttonId != 0) {
// Log.d(TAG, "MAKING radiobutton setChecked(true)...");
radiobutton = (RadioButton) findViewById(radiobuttonId);
Log.d(TAG, "radiobutton @onStart = " + radiobutton.toString());
radiobutton.setTextColor(Color.parseColor(primeColorString));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
radiobutton.setBackground(getDrawable(R.drawable.underline));
} else {
radiobutton.setPaintFlags(radiobutton.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
}
radiobutton.setClickable(true);
radiobutton.setChecked(false);
lastButton = radiobutton;
Log.d(TAG, "checkbusSelection = " + checkBusSelection);
}
if (pickMeRadioButtonId != -1) {
pickMeRadioButton = (RadioButton) findViewById(pickMeRadioButtonId);
pickMeRadioButton.setTypeface(Typeface.DEFAULT_BOLD);
pickMeRadioButton.setTextColor(getResources().getColor(R.color.primeColor));
}
flagOnChild = 1;
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
Aggregations