Reputation: 67
I'm trying to implement the google auto complete widget with some code from the Google website. I'm having one error on this line:
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener()
the error being: class 'Anonymous class derived from PlaceSelectedListener' must either be declared abstract or implement abstract method 'onError(Status)' in 'PlaceSelectionListener'
and the other error on this one:
@Override
public void onError(AsyncTask.Status status
whereby the error is: Method does not override method from its superclass
Can I please get insight on how to solve these errors?
public class Preferences extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preferences);
final TextView text = (TextView)findViewById(R.id.textView3);
final String TAG = Preferences.class.getSimpleName();
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
Log.i(TAG, "Place: " + place.getName());
String placeDetailsStr = place.getName() + "\n"
+ place.getId() + "\n"
+ place.getLatLng().toString() + "\n"
+ place.getAddress() + "\n"
+ place.getAttributions();
text.setText(placeDetailsStr);
}
@Override
public void onError(AsyncTask.Status status) {
// TODO: Handle the error.
Log.i(TAG, "An error occurred: " + status);
}
});
}
}
Upvotes: 1
Views: 2183
Reputation: 67
I found the solution: I changed:
@Override
public void onError(AsyncTask.Status status) {
// TODO: Handle the error.
Log.i(TAG, "An error occurred: " + status);
}
to:
@Override
public void onError(Status status) {
Log.i(TAG, "An error occurred: " + status);
}
Upvotes: 2