Set spinner within custom dialog
Date : March 29 2020, 07:55 AM
wish of those help I have managed to fix the issue. It was very subtle and I'm pretty sure I got lucky. Here's the working code: protected Dialog onCreateDialog(int id)
{
Dialog dialog;
switch(id) {
case DIALOG_SEND_PM:
dialog = new Dialog(PM.this);
dialog.setContentView(R.layout.send_pm_dialog);
dialog.setTitle(R.string.send_pm);
pmMessage = (EditText) dialog.findViewById(R.id.send_pm_box);
Button sendPm = (Button) dialog.findViewById(R.id.send_pm_button);
sendPm.setOnClickListener(PM.this);
Spinner spinner = (Spinner)dialog.findViewById(R.id.pm_server);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.server_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
break;
default:
dialog = null;
}
return dialog;
}
|
Custom Spinner doesnt show the value returned from custom Dialog
Date : March 29 2020, 07:55 AM
this will help I simply removed the adapter class declared in CustomSpinner class, also removed this constructor: public CustomSpinner(Context context, String[] dataList)
{
super(context);
this.mContext = context;
this.mDataList = dataList;
}
cSpinner= (CustomSpinner) findViewById(R.id.customSpinner);
cSpinner.setDataList(dataList);
cSpinner.setTag("CustomSpinner");
cSpinner.setOnItemSelectedListener(controller);
cSpinner = (CustomSpinner)findViewById(R.id.customSpinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.options_array, R.layout.spinner_target);
cSpinner .setAdapter(adapter);
cSpinner .setTag("CustomSpinner");
cSpinner .setOnItemSelectedListener(controller);
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinnerTarget"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:padding="8dp"/>
|
Android spinner display custom dialog
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , As @Vigneshearan.m said: The solution is to override the onTouch method of the spinner class. _spinnerLand.Touch += (sender, e) => {
if (builder == null)
{
builder = new AlertDialog.Builder (_activity);
builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon);
builder.SetTitle ("Test");
builder.SetMessage("This is just a test");
builder.SetPositiveButton (Android.Resource.String.Ok, delegate (object o, DialogClickEventArgs ea) {builder = null;});
builder.Create();
builder.Show();
}
};
|
Spinner with custom objects list inside custom Dialog Fragment not working
Date : March 29 2020, 07:55 AM
|
Custom spinner dialog for Android
Tag : android , By : Hugo Hernan Buitrago
Date : March 29 2020, 07:55 AM
|