List of usage examples for android.widget RadioButton toggle
@Override public void toggle()
If the radio button is already checked, this method will not toggle the radio button.
From source file:com.sweetiepiggy.littlepro.QuestionFragment.java
private void createMultipleChoice(View v, List<String> answerChoices) { v.findViewById(R.id.answer).setVisibility(View.GONE); RadioGroup radioGroup = (RadioGroup) v.findViewById(R.id.answerRadioGroup); for (String answerChoice : answerChoices) { RadioButton radioButton = new RadioButton(getActivity()); radioButton.setText(answerChoice); radioButton.setTextAppearance(getActivity(), R.style.Entry); radioGroup.addView(radioButton); if (answerChoice == mAnswer) { radioButton.toggle(); }//from w ww .j a v a2s . com if (mSubmitted) { radioButton.setEnabled(false); } } }
From source file:ru.orangesoftware.financisto2.activity.FlowzrSyncActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FlowzrSyncActivity.me = this; mNotifyBuilder = new NotificationCompat.Builder(getApplicationContext()); nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); setContentView(R.layout.flowzr_sync); restoreUIFromPref();//from w w w .j a v a 2 s. c o m if (useCredential != null) { } AccountManager accountManager = AccountManager.get(getApplicationContext()); final Account[] accounts = accountManager.getAccountsByType("com.google"); if (accounts.length < 1) { new AlertDialog.Builder(this).setTitle(getString(R.string.flowzr_sync_error)) .setMessage(R.string.account_required) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }).show(); } //radio crendentials RadioGroup radioGroupCredentials = (RadioGroup) findViewById(R.id.radioCredentials); OnClickListener radio_listener = new OnClickListener() { public void onClick(View v) { RadioButton radioButtonSelected = (RadioButton) findViewById(v.getId()); for (Account account : accounts) { if (account.name == radioButtonSelected.getText()) { useCredential = account; } } } }; //initialize value for (int i = 0; i < accounts.length; i++) { RadioButton rb = new RadioButton(this); radioGroupCredentials.addView(rb); //, 0, lp); rb.setOnClickListener(radio_listener); rb.setText(((Account) accounts[i]).name); if (useCredential != null) { if (accounts[i].name.equals(useCredential.name)) { rb.toggle(); //.setChecked(true); } } } bOk = (Button) findViewById(R.id.bOK); bOk.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setRunning(); initProgressDialog(); // if (useCredential!=null) { // flowzrBilling=new FlowzrBilling(FlowzrSyncActivity.this, getApplicationContext(), http_client, useCredential.toString()); // } if (useCredential == null) { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_choose_account); notifyUser(getString(R.string.flowzr_choose_account), 100); setReady(); } else if (!isOnline(FlowzrSyncActivity.this)) { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); notifyUser(getString(R.string.flowzr_sync_error_no_network), 100); setReady(); } else { saveOptionsFromUI(); //Play Service Billing //FlowzrBilling flowzrBilling = new FlowzrBilling(FlowzrSyncActivity.this, getApplicationContext(), http_client, useCredential.toString()); //if (flowzrSyncTask.checkSubscription()) { flowzrSyncEngine = new FlowzrSyncEngine(FlowzrSyncActivity.this); //} } } }); Button bCancel = (Button) findViewById(R.id.bCancel); bCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (flowzrSyncEngine != null) { flowzrSyncEngine.isCanceled = true; } isRunning = false; setResult(RESULT_CANCELED); setReady(); startActivity(new Intent(getApplicationContext(), MainActivity.class)); //finish(); } }); Button textViewAbout = (Button) findViewById(R.id.buySubscription); textViewAbout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(useCredential); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr); textViewAboutAnon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(null); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote); textViewNotes.setMovementMethod(LinkMovementMethod.getInstance()); textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use))); if (MyPreferences.isAutoSync(this)) { if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(getApplicationContext()); if (regid.equals("")) { registerInBackground(); } Log.i(TAG, "Google Cloud Messaging registered as :" + regid); } else { Log.i(TAG, "No valid Google Play Services APK found."); } } }
From source file:ru.orangesoftware.financisto.activity.FlowzrSyncActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FlowzrSyncActivity.me = this; mNotifyBuilder = new NotificationCompat.Builder(getApplicationContext()); nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); setContentView(R.layout.flowzr_sync); restoreUIFromPref();// ww w.j av a 2 s. c o m AccountManager accountManager = AccountManager.get(getApplicationContext()); final Account[] accounts = accountManager.getAccountsByType("com.google"); if (accounts.length < 1) { new AlertDialog.Builder(this).setTitle(getString(R.string.flowzr_sync_error)) .setMessage(R.string.account_required) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }).show(); } //checkbox CheckBox chk = (CheckBox) findViewById(R.id.chk_sync_from_zero); OnClickListener chk_listener = new OnClickListener() { public void onClick(View v) { lastSyncLocalTimestamp = 0; renderLastTime(0); flowzrSyncEngine.resetLastTime(getApplicationContext()); } }; chk.setOnClickListener(chk_listener); //radio crendentials RadioGroup radioGroupCredentials = (RadioGroup) findViewById(R.id.radioCredentials); OnClickListener radio_listener = new OnClickListener() { public void onClick(View v) { RadioButton radioButtonSelected = (RadioButton) findViewById(v.getId()); for (Account account : accounts) { if (account.name == radioButtonSelected.getText()) { lastSyncLocalTimestamp = 0; renderLastTime(0); flowzrSyncEngine.resetLastTime(getApplicationContext()); useCredential = account; } } } }; radioGroupCredentials.setOnClickListener(radio_listener); //initialize value for (int i = 0; i < accounts.length; i++) { RadioButton rb = new RadioButton(this); radioGroupCredentials.addView(rb); //, 0, lp); rb.setOnClickListener(radio_listener); rb.setText(((Account) accounts[i]).name); String prefAccount = MyPreferences.getFlowzrAccount(this); if (prefAccount != null) { if (accounts[i].name.equals(prefAccount)) { useCredential = accounts[i]; rb.toggle(); //.setChecked(true); } } } bOk = (Button) findViewById(R.id.bOK); bOk.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { startSync(); } }); Button bCancel = (Button) findViewById(R.id.bCancel); bCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (flowzrSyncEngine != null) { flowzrSyncEngine.isCanceled = true; } isRunning = false; setResult(RESULT_CANCELED); setReady(); startActivity(new Intent(getApplicationContext(), MainActivity.class)); //finish(); } }); Button textViewAbout = (Button) findViewById(R.id.buySubscription); textViewAbout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(useCredential); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr); textViewAboutAnon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(null); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote); textViewNotes.setMovementMethod(LinkMovementMethod.getInstance()); textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use))); if (MyPreferences.isAutoSync(this)) { if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(getApplicationContext()); if (regid.equals("")) { registerInBackground(); } Log.i(TAG, "Google Cloud Messaging registered as :" + regid); } else { Log.i(TAG, "No valid Google Play Services APK found."); } } }