2 つの数値ピッカーを文字列に変換しようとしていますが、うまくいかないようです。
私はNPEを取得し続けており、原因を突き止めることができないようです.
以下のコードと Logcat を参照してください。
どんな助けでも大歓迎です。
以下はonCreate内にあります.....
final Context context = this;
LayoutInflater li = LayoutInflater.from(context);
View promptsView = li.inflate(R.layout.custominout, null);
AlertDialog.Builder renamedialog = new AlertDialog.Builder(context);
renamedialog.setTitle("Custom output change");
renamedialog.setView(promptsView);
int minInValue = 1;
int maxInValue = 16;
int currentInValue = 1;
final NumberPicker inCapacity = (NumberPicker) promptsView.findViewById(R.id.inpicker);
inCapacity.setMinValue(minInValue);
inCapacity.setMaxValue(maxInValue);
inCapacity.setValue(currentInValue);
int minOutValue = 1;
int maxOutValue = 16;
int currentOutValue = 1;
final NumberPicker outCapacity = (NumberPicker) promptsView.findViewById(R.id.outpicker);
outCapacity.setMinValue(minOutValue);
outCapacity.setMaxValue(maxOutValue);
outCapacity.setValue(currentOutValue);
renamedialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
whatin = (NumberPicker) findViewById(R.id.inpicker);
whatout = (NumberPicker) findViewById(R.id.outpicker);
String inpicker = String.valueOf(whatin.getValue());
String outpicker = String.valueOf(whatout.getValue());
try {
CustomInOut cus = new CustomInOut();
cus.setInpicker(inpicker);
cus.setOutpicker(outpicker);
cus.execute();
} catch(IllegalStateException e) {}
}
});
renamedialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Write your code here to invoke NO event
dialog.cancel();
}
});
LogCat
01-04 11:58:39.278: E/AndroidRuntime(1432): FATAL EXCEPTION: main
01-04 11:58:39.278: E/AndroidRuntime(1432): java.lang.NullPointerException
01-04 11:58:39.278: E/AndroidRuntime(1432): at com.smarte.smartipcontrol.IPControl$1.onClick(IPControl.java:98)
01-04 11:58:39.278: E/AndroidRuntime(1432): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
01-04 11:58:39.278: E/AndroidRuntime(1432): at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 11:58:39.278: E/AndroidRuntime(1432): at android.os.Looper.loop(Looper.java:137)
01-04 11:58:39.278: E/AndroidRuntime(1432): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-04 11:58:39.278: E/AndroidRuntime(1432): at java.lang.reflect.Method.invokeNative(Native Method)
01-04 11:58:39.278: E/AndroidRuntime(1432): at java.lang.reflect.Method.invoke(Method.java:511)
01-04 11:58:39.278: E/AndroidRuntime(1432): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-04 11:58:39.278: E/AndroidRuntime(1432): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-04 11:58:39.278: E/AndroidRuntime(1432): at dalvik.system.NativeStart.main(Native Method)