我想做以下事项:当检查复选框时,将出现TextView,然后用户可以放置任何他需要的东西,但问题是我无法在edittext中获取文本以将它放在一个字符串变量中,因为它需要进入 if 语句时的初始值为“nothing”。有什么帮助吗?
我是这个网站的新手,这是我正在谈论的代码部分
SendSMS.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked == true) {
sendText.setVisibility(0);
smstext = sendText.getText().toString();
} else if (isChecked == false) {
sendText.setVisibility(8);
smstext = "";
}
}
});
这里..检查sendms到true后会出现edittext(sendText)
. . . . . .
在这里,当用户输入任何文本时,我需要将其放入要存储在数据库中的字符串(短信)中,抱歉出现错误
break;
case R.id.SaveImage:
String x = EventName.getText().toString();
if (x.contentEquals("")) {
Toast.makeText(getApplicationContext(), "Enter a Title",
Toast.LENGTH_SHORT).show();
} else {
Intent i = new Intent(getApplicationContext(), Swipe.class);
startActivity(i);
Toast.makeText(getApplicationContext(), "Event saved",
Toast.LENGTH_SHORT).show();
String typename = type;
String name = EventName.getText().toString();
String location = EventLocation.getText().toString();
String dateFrom = DateFrom.getText().toString();
String dateTo = EbDate.getText().toString();
String timeFrom = mPickTime.getText().toString();
String timeTo = EbTime.getText().toString();
String duration = durationresult.getText().toString();
String alarm = alarmresult.getText().toString();
String repeat = repeatresult.getText().toString();
String audios = Audios;
String sms = smstext;
String call = calltext;
mySQLiteAdapter.insert(name, location, dateFrom, dateTo,
timeFrom, timeTo, duration, alarm, repeat, typename,
audios, sms, call);
updateList();
// reset form
EventName.setText(null);
EventLocation.setText(null);
break;
}
}
}