【发布时间】:2017-04-28 05:35:32
【问题描述】:
我在用户应该填写的片段中有两个 AutoCompleteTextView。然后这两个字符串值必须发送到其他活动,否则(如果它没有填充)你应该看到一个 toast。我试图实现它,但它不起作用:
public void onFindPathClick(View view) {
String originAddress = OriginPlaceFragment.mAutoPlaceSearch.getText().toString();
String destinationAddress = DestinationPlaceFragment.mAutoPlaceSearch.getText().toString();
Intent intent = new Intent(SimpleTabsActivity.this, MapsActivity.class);
if ((originAddress != "") && (!originAddress.equals(null)) && (destinationAddress != "") && (!destinationAddress.equals(null))) {
intent.putExtra(ORIGIN_ADDRESS, originAddress);
intent.putExtra(DESTIN_ADDRESS, destinationAddress);
startActivity(intent);
} else {
Toast.makeText(this, "Fill \"from\" and \"to\" fields", Toast.LENGTH_SHORT).show();
}
}
【问题讨论】:
-
如果它给出异常会发生什么。把它放在问题上,我也希望 onFindPathClick 绑定到一个事件?
标签: java android autocomplete