/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Tell AQUtility about context: it can use this globally...which is really handy! AQUtility.setContext(getApplication()); // Load default preferences PreferenceManager.setDefaultValues(this, R.xml.preferences, false); findAllViewsById(); View.OnClickListener radioButtonListener = new View.OnClickListener() { public void onClick(View v) { RadioButton radioButton = (RadioButton) v; searchTypeTextView.setText("Searching for " + radioButton.getText()); } }; moviesSearchRadioButton.setOnClickListener(radioButtonListener); peopleSearchRadioButton.setOnClickListener(radioButtonListener); searchButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { String query = searchEditText.getText().toString(); if (moviesSearchRadioButton.isChecked()) { PerformFilmSearchTask task = new PerformFilmSearchTask(FilmSearchAppActivity.this); task.execute(query); } else if (peopleSearchRadioButton.isChecked()) { PerformPersonSearchTask task = new PerformPersonSearchTask(FilmSearchAppActivity.this); task.execute(query); } } }); int radioId = searchRadioGroup.getCheckedRadioButtonId(); RadioButton radioButton = (RadioButton) findViewById(radioId); searchTypeTextView.setText(radioButton.getText()); }