xml 파일의 사용자 정의 레이아웃이있는 alertdialog가 있습니다. 번호 선택 도구를 작동 시키려면 몇 가지 값을 설정해야합니다. 어떻게 관리 할 수 있습니까? ShowMap 클래스의경고 대화 상자에서 숫자 선택기에 값을 설정하십시오.
글로벌 바르 :
AlertDialog.Builder alert; //dialog f. koord.
static Dialog d ;
NumberPicker np1, np2, np3, np4, np5, np6, np7, np8;
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" };
String zero_to_99[] = new String[100];
이 ShowDialog() :
public void showDialog()
{
final Context context=getApplicationContext();
//final Dialog d = new Dialog(ShowMap.this);
//Creating the AlertDialog object
final AlertDialog.Builder d = new AlertDialog.Builder(this);
//customDialog.setTitle("Custom Dialog");
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);
np1 = (NumberPicker) findViewById(R.id.p1);
np2 = (NumberPicker) findViewById(R.id.p2);
np3 = (NumberPicker) findViewById(R.id.p3);
np4 = (NumberPicker) findViewById(R.id.p4);
np5 = (NumberPicker) findViewById(R.id.p5);
np6 = (NumberPicker) findViewById(R.id.p6);
np7 = (NumberPicker) findViewById(R.id.p7);
np8 = (NumberPicker) findViewById(R.id.p8);
//d.setContentView(R.layout.dialog_pick_coord);
d.setPositiveButton(context.getResources().getString(R.string.Accept), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Code to read out the pickers and work with the values
}
});
d.setNegativeButton(context.getResources().getString(R.string.Cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
d.setView(view);
d.show();
}
setAlertDialogValues :
public void setAlertDialogValues() {
//Spalte
np1.setMaxValue(60); // max value 60
np1.setMinValue(1); // min value 1
np1.setWrapSelectorWheel(false);
//Zeile
np2.setMaxValue(25); // max value Z
np2.setMinValue(0); // min value A
np2.setDisplayedValues(abc);
np2.setWrapSelectorWheel(false);
//100km Quadrat 1
np3.setMaxValue(25); // max value Z
np3.setMinValue(0); // min value A
np3.setDisplayedValues(abc);
np3.setWrapSelectorWheel(false);
//100km Quadrat 2
np4.setMaxValue(25); // max value Z
np4.setMinValue(0); // min value A
np4.setDisplayedValues(abc);
np4.setWrapSelectorWheel(false);
//Easting xx*
np5.setMaxValue(99); // max value 99
np5.setMinValue(0); // min value 0
np5.setDisplayedValues(zero_to_99);
np5.setWrapSelectorWheel(false);
//Easting **x
np6.setMaxValue(9); // max value 9
np6.setMinValue(0); // min value 0
np6.setWrapSelectorWheel(false);
//Northing xx*
np7.setMaxValue(99); // max value 99
np7.setMinValue(0); // min value 0
np7.setDisplayedValues(zero_to_99);
np7.setWrapSelectorWheel(false);
//Northing **x
np8.setMaxValue(9); // max value 9
np8.setMinValue(0); // min value 0
np8.setWrapSelectorWheel(false);
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.show
후를 호출 할 때 나는 오류를 받고 있어요 ...
어디서 나는 (...) findViewById를해야합니까? alertdialog가 표시 될 때 호출되는 메소드가 있습니까? –
오류 게시하기. – JoxTraex
nullpointerException "np1.setMaxValue (60); \t // 최대 값 60" –