我的findViewById抛出错误,说它尚未定义,它要求我创建一个函数。我该怎么办?
public void geoLocate(View v) throws IOException {
hideSoftKeyboard(v);
EditText et = (EditText) findViewById(R.id.editText1);
String location = et.getText().toString();
Geocoder gc = new Geocoder(context);
List<Address> list = gc.getFromLocationName(location, 1);
Address add = list.get(0);
String locality = add.getLocality();
Toast.makeText(context, locality, Toast.LENGTH_LONG).show();
double lat = add.getLatitude();
double lng = add.getLatitude();
gotoLocation(lat, lng, DEFAULTZOOM);
MarkerOptions markerOptions = new MarkerOptions().title(locality).position(new LatLng(lat,lng));
mMap.addMarker(markerOptions);
}
答案 0 :(得分:0)
在你的函数中找到这样的id
EditText et = (EditText) v.findViewById(R.id.editText1);
您需要使用方法中传递的View变量来查找id