First time asking question..How do i solve the problem of radio button unchecked when i scrolling in listview?(I am doing a simple survey app with 10questions)
MainActivity.java
public class MainActivity extends AppCompatActivity {
ListView listView;
String[] questions;
Button submit;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    questions = getResources().getStringArray(R.array.questions);
    listView =(ListView) findViewById(R.id.listView);
    CustomAdapter customAdapter = new CustomAdapter(getApplicationContext(), questions);
    listView.setAdapter(customAdapter);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String message = "";
            // get the value of selected answers from custom adapter
            for (int i = 0; i < CustomAdapter.selectedAnswers.size(); i++) {
                message = message + "\n" + (i + 1) + " " + CustomAdapter.selectedAnswers.get(i);
            }
            // display the message on screen with the help of Toast.
            Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
        }
    });
}
CustomAdapter.java
public class CustomAdapter extends BaseAdapter {
Context context;
String[] questionsList;
LayoutInflater inflter;
public static ArrayList<String> selectedAnswers;
public CustomAdapter(Context applicationContext, String[] questionsList) {
    this.context = context;
    this.questionsList = questionsList;
    // initialize arraylist and add static string for all the questions
    selectedAnswers = new ArrayList<>();
    for (int i = 0; i < questionsList.length; i++) {
        selectedAnswers.add("Not Attempted");
    }
    inflter = (LayoutInflater.from(applicationContext));
}
@Override
public int getCount() {
    return questionsList.length;
}
@Override
public Object getItem(int i) {
    return null;
}
@Override
public long getItemId(int i) {
    return 0;
}
@Override
public View getView(final int i, View view, ViewGroup viewGroup) {
    view = inflter.inflate(R.layout.questions, null);
    // get the reference of TextView and Button's
    TextView question = (TextView) view.findViewById(R.id.question);
    RadioButton radioButton = (RadioButton) view.findViewById(R.id.radioButton);
    RadioButton radioButton2 = (RadioButton) view.findViewById(R.id.radioButton2);
    RadioButton radioButton3 = (RadioButton) view.findViewById(R.id.radioButton3);
    RadioButton radioButton4 = (RadioButton) view.findViewById(R.id.radioButton4);
    RadioButton radioButton5 = (RadioButton) view.findViewById(R.id.radioButton5);
    // perform setOnCheckedChangeListener event on yes button
    radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // set Yes values in ArrayList if RadioButton is checked
            if (isChecked)
                selectedAnswers.set(i, "");
        }
    });
    // perform setOnCheckedChangeListener event on no button
    radioButton2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // set No values in ArrayList if RadioButton is checked
            if (isChecked)
                selectedAnswers.set(i, "");
        }
    });
    radioButton3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // set No values in ArrayList if RadioButton is checked
            if (isChecked)
                selectedAnswers.set(i, "");
        }
    });
    radioButton4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // set No values in ArrayList if RadioButton is checked
            if (isChecked)
                selectedAnswers.set(i, "");
        }
    });
    radioButton5.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // set No values in ArrayList if RadioButton is checked
            if (isChecked)
                selectedAnswers.set(i, "");
        }
    });
    // set the value in TextView
    question.setText(questionsList[i]);
    return view;
    }
}
 
     
     
    