2

いくつかの座標入力を取得するために、アラート ダイアログで xml ファイルからいくつかの番号ピッカーを使用しています。ピッカーが作成され、いくつかの値があります (マークしてキーボードを開くと表示されます) が、他の値は表示されず、表示される値は背景と同じ色になります。OK ボタンを押すと、(多かれ少なかれ) 表示された値がアクティビティに正しく与えられます。

私のコード:

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();
}

「メイン アクティビティ」には、showDialog() メソッドを呼び出す onClickListeners を持つボタンがあります。

スクリーンショット

4

0 に答える 0