如果字符串有值,我的代码可以正常工作。但是,如果字符串为空,则会发生应用程序强制关闭。如何处理空字符串值?请帮帮我。
String value;
int value1;
String completedate;
e01 = (Button) findViewById(R.id.e01);
case R.id.e01:
value = e01.getText().toString();
if (value != null) {
value1 = Integer.parseInt(value);
completedate = String.format("%02d", value1)
+ String.format("%02d", mMonth)
+ mYear;
Toast.makeText(this, url +completedate, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Date not Available",
Toast.LENGTH_SHORT).show();
// string is Null......
}
break;