Question

I'm using some number pickers from a xml-file in a alert dialog to get some coordinate inputs. The pickers are created and have some values (when you mark it and the keyboard opens you can see them), but won't show other values and the displayed value has the same color as the background. When I press the OK-Button, the (more or less) displayed values are given correctly to the activity.

My Code:

public void showDialog()
{
     final Context context=getApplicationContext();
     final AlertDialog.Builder d = new AlertDialog.Builder(this);

     final NumberPicker np1, np2, np3, np4, np5, np6, np7, np8;
     final String abc[] = new String[] { "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z" }; 
     final String zero_to_99[] = new String[100];
     //init string array
     for(int i=0; i<=99; i++)
     {
         zero_to_99[i] = Integer.toString(i);
         if(zero_to_99[i].length() == 1)
             zero_to_99[i] = "0"+Integer.toString(i);
     }

     LayoutInflater layoutInflater = (LayoutInflater)getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
     View view=layoutInflater.inflate(R.layout.dialog_pick_coord,null);

     String txt_title = context.getResources().getString(R.string.txt_head_search_coord);
     d.setTitle(txt_title);

     //Spalte
     np1 = (NumberPicker) view.findViewById(R.id.p1);
     np1.setMaxValue(60);   // max value 60
     np1.setMinValue(1);    // min value 1
     np1.setWrapSelectorWheel(false);

     //Zeile
     np2 = (NumberPicker) view.findViewById(R.id.p2);
     np2.setMaxValue(25);   // max value Z
     np2.setMinValue(0);    // min value A
     np2.setDisplayedValues( abc );
     np2.setWrapSelectorWheel(false);

     //100km Quadrat 1
     //more number pickers

     //100km Quadrat 2
     //more number pickers

     //Easting xx*
     //more number pickers

     //Easting **x
     //more number pickers

     //Northing xx*
     //more number pickers

     //Northing **x
     //more number pickers


     np1.setValue(utmCoordElements[0]);
     np2.setValue(utmCoordElements[1]);
     np3.setValue(utmCoordElements[2]);
     np4.setValue(utmCoordElements[3]);
     np5.setValue(utmCoordElements[4]);
     np6.setValue(utmCoordElements[5]);
     np7.setValue(utmCoordElements[6]);
     np8.setValue(utmCoordElements[7]);

     d.setPositiveButton(context.getResources().getString(R.string.Accept), new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
             //Code for click on positive button
         }
     });

     d.setNegativeButton(context.getResources().getString(R.string.Cancel), new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
             //Code for click on negative button
         }
     });     

     d.setView(view);
     d.show();
}

In my "main activity" I have a Button with a onClickListeners wich calls the showDialog() Method

screenshot

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top