Reasons for receiving “RadioGroup is not applicable for the arguments”


I am implementing <strong>RadioGroup</strong> in my application. For that I have imported import android.widget.RadioGroup and implemented OnCheckedChangeListener. But still I am getting this error:


The method setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener) in the type RadioGroup is not applicable for the arguments (OpenedClass)





</blockquote> public class OpenedClass extends Activity implements OnClickListener,OnCheckedChangeListener{ TextView tv1,tv2; RadioGroup selectionList; Button rtn; String gotBread; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.send); initlize(); Bundle gotBusket = getIntent().getExtras(); gotBread = gotBusket.getString("KEY"); tv1.setText(gotBread); } private void initlize() { // TODO Auto-generated method stub tv1 = (TextView)findViewById(R.id.tvQuestion); tv2 = (TextView)findViewById(R.id.textView2); rtn = (Button)findViewById(R.id.bReturn); rtn.setOnClickListener(this); selectionList = (RadioGroup)findViewById(R.id.rgAnswers); selectionList.setOnCheckedChangeListener(this); } @Override public void onClick(View arg0) { // TODO Auto-generated method stub } @Override public void onCheckedChanged(CompoundButton arg0, boolean arg1) { // TODO Auto-generated method stub switch(arg0.getId()) { case R.id.rCrazy: break; case R.id.rSuper: break; case R.id.rBoth: break; } } }


You are importing an incorrect class of OnCheckedChangeListener for RadioGroup.


import android.widget.CompoundButton.OnCheckedChangeListener;

with this one:

import android.widget.RadioGroup.OnCheckedChangeListener;

and fix your interface implementation as below:

@Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch(checkedId) { //your cases } }


During creating the oncheckedchangelistener(), specifying "new RadioGroup.OnCheckedChangeListener()" instead of just "OnCheckedChangeListener()" fixed the problem.

Adding the sample code for others reference.

RadioGroup rdGroup = (RadioGroup) findViewById(R.id.rdbGp1); rdGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub } });


You are importing an incorrect class of OnCheckedChangeListener


  • android application not connecting to mssql server 2008
  • How to receive the actions made by the user in a DialogFragment?
  • Small project in Android
  • Firebase - retrieve data in Android
  • Is Android's ARGB_8888 Bitmap internal format always RGBA?
  • OnItemSelectedListener for Spinner that was added programmatically does not trigger
  • Replace Fragment with another on back button
  • Avoid registering duplicate broadcast receivers in Android
  • How to get listview position?
  • Laravel: Getting Session ID oddly truncates when using foreach
  • Bypass multiple inheritance in Java
  • Connect .sks to skscene.h
  • Date Conversion from yyyy-mm-dd to dd-mm-yyyy
  • Passing 1 of 3 values to a Sub
  • How to test if a URL from an Eclipse bundle is a directory?
  • ActiveRecord query for a count of new users by day
  • Set the selected item in dropdownlist in MVC3
  • How to create a file in java without a extension
  • Recording logins for password protected directories
  • how to do an event when i swipe from fragment to the other
  • Spring Data JPA custom method causing PropertyReferenceException
  • Update CALayer sublayers immediately
  • Splitting given String into two variables - php
  • JFileChooser in front of fullscreen Swing application
  • What is Eclipse's Declaration View used for?
  • Counter field in MS Access, how to generate?
  • Possible to stop flickering java tooltip in heavyweight mode?
  • sending/ receiving email in Java
  • How to set my toolbar fixed while scrolling android
  • AT Commands to Send SMS not working in Windows 8.1
  • Cannot Parse HTML Data Using Android / JSOUP
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • apache spark aggregate function using min value
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • Sorting a 2D array using the second column C++
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?