List of usage examples for android.widget RadioGroup setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
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();//from w w w . j a v 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."); } } }