0
I’m using Google Places API for Android for suggestion of addresses in input fields. This API uses Googleapiclient to operate.
The app
has a fragment composed of a recyclerview
and a FAB
.
On touching the FAB
, the user opens a dialog with form. input. In this form. has a field AutoCompleteTextView
to enter the address. This field has a Adapter to the Googleapiclient and displays address suggestions as the user enters the data.
This part is ready.
As data are entered, the recyclerview
will display this data in cards. When you click on a card, another dialog opens, this time for data editing.
And here’s the problem. I don’t know how to use the Googleapiclient in the recyclerview Adapter.
I tried to create another Googleapiclient in the class extending RecyclerView.Adapter
, but did not know how to do or is not around.
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 onCreateView
from Fragment. I tried to instantiate mGoogleApiClient on onCreateViewHolder
and in the onBindViewHolder, ele não aceita nada como 1º parametro de
enableAutoManage`.
The question is: how do I use the Googleapiclient in a fragment that has recyclerciew and also in events of the items of this same recyclerview?