FirstI'm trying to display the spinner into a dialog, I'm calling the data from database into ArrayList via getData object and everything is working fine but in the last step I got the above error when I tried to assign the adapter to the spinner and here is my code :
public class ViewDialogCities {
public void showDialog(int layoutID , Activity activity){
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(layoutID);
Button OkButton = dialog.findViewById(R.id.btn_dialog_ddl_ok);
Button CloseDialogButton = dialog.findViewById(R.id.btn_dialog_ddl_cancel);
Spinner spn_ddl_dialog_list = findViewById(R.id.spn_ddl_dialog_list);
//Define data object
final GetData getData = new GetData();
ArrayList<String> getListOf;
//Retrieve data from data object and store it an ArrayList
getListOf = getData.getListOf("R");
//ArrayList to ArrayAdapter
ArrayAdapter<String> arrayAdapter = new ArrayAdapter
( HomeActivity.this, android.R.layout.simple_spinner_dropdown_item, getListOf);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Assign ArrayAdapter to spinner
spn_ddl_dialog_list.setAdapter(arrayAdapter);
CloseDialogButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
OkButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
dialog.show();
}
}