Я хочу добавить следующие строковые данные в текстовое представление. Поскольку я новичок, я не могу понять, как их добавить. Пожалуйста, помогите мне. Я хочу добавить nameOfplace, адрес, рейтинг в текстовом виде. Метод DisplayNearByplaces () подключен к методу onPostExecute ().
public class PlaceAdapter extends RecyclerView.Adapter<PlaceAdapter.MyViewHolder> {
List<String> data;
Context context;
public PlaceAdapter(List<String> data, Context context) {
this.data = data;
this.context = context;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.details_row, parent, false));
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
}
@Override
public int getItemCount() {
return data.size();
}
public void DisplayNearByPlaces(List<HashMap<String, String>> nearByPlacesList) {
for (int i = 0; i < nearByPlacesList.size(); i++) {
HashMap<String, String> googleNearByPlaces = nearByPlacesList.get(i);
String nameOfPlace = googleNearByPlaces.get("place_name");
String vicinity = googleNearByPlaces.get("vicinity");
String reference = googleNearByPlaces.get("reference");
double lat = Double.parseDouble(googleNearByPlaces.get("lat"));
double lng = Double.parseDouble(googleNearByPlaces.get("lng"));
String address = googleNearByPlaces.get("formatted_address");
String rating = googleNearByPlaces.get("rating");
}
}
public class MyViewHolder extends RecyclerView.ViewHolder {
TextView t1, t2, t3, t4;
Button sel;
ImageButton gmap;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
t1 = (TextView) itemView.findViewById(R.id.place_name);
t2 = (TextView) itemView.findViewById(R.id.address);
t3 = (TextView) itemView.findViewById(R.id.distance);
t4 = (TextView) itemView.findViewById(R.id.rating);
sel = (Button) itemView.findViewById(R.id.sel_place);
gmap = (ImageButton) itemView.findViewById(R.id.map_place);
}
}
}