I'm using Google Places API for Android to suggest addresses in input fields. This API uses GoogleAPIClient to operate.
The app
has a fragment consisting of recyclerview
and FAB
.
When you touch FAB
, the user opens a dialog with form. input. In this form. has a AutoCompleteTextView
field to enter the address. This field has a adapter for the GoogleAPIClient and shows suggestions for addresses as the user enters the data.
This part is ready.
As data is entered, recyclerview
will display this data on cards. When you click on a card, another dialog is opened, this time for editing the data.
And here's the problem. I am not sure how to use the GoogleAPIClient in the recyclerview adapter.
I tried to create another GoogleAPIClient in the class that extends RecyclerView.Adapter
, but did not know how to do it or not.
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_recycler, container, false);
mGoogleApiClient = new GoogleApiClient.Builder(getContext())
.addApi(Places.GEO_DATA_API)
.enableAutoManage(getActivity(), GOOGLE_API_CLIENT_ID, this)
.addConnectionCallbacks(this)
.build();
mPlaceArrayAdapter = new PlaceArrayAdapter(getContext(), android.R.layout.simple_list_item_1,
BOUNDS_AUTOCOMPLETE, null);
This is the% code of the% fragment. I tried to instantiate mGoogleApiClient in onCreateView
and onCreateViewHolder
enableAutoManage '.
The question is: How do I use GoogleApiClient in a fragment that has recyclerciew and also in events of the items in this same recyclerview?