я начинаюсь с recyclerview и в момент загружения listaRestaurant объект restaurant, загружаю данные, но не изображение. Изображение загрузило ее url поисковой службы google. app не закрывается, выполнив и также debug ничего не помечает, просто не видно изображение, я продолжил шаги руководителя буквально, но я не могу встретить проблемы
//aca seteo
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.mItem = mValues.get(position);
holder.textViewNombreRestaurante.setText(holder.mItem.getNombre());
holder.textViewDireccionRestaurante.setText(holder.mItem.getDireccion());
holder.ratingBarRestaurante.setRating(holder.mItem.getValoracion());
Picasso.get().load(holder.mItem.getUrlPhoto()).into(holder.imageViewPhotoRestaurante);
holder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != mListener) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
mListener.onListFragmentInteraction(holder.mItem);
}
}
});
}
потом я определяю стоимость для каждого элемента
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.fragment_restaurante_list, container, false);
// Set the adapter
if (v instanceof RecyclerView) {
Context context = v.getContext();
recyclerView = (RecyclerView) v;
if (mColumnCount <= 1) {
recyclerView.setLayoutManager(new LinearLayoutManager(context));
} else {
recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
}
//lita elementos (rastaurantes)
restauranteList=new ArrayList<>();
restauranteList.add(new Restaurante("Pizzeria Las Cuartetas","https://placeralplato.com/files/2016/01/Pizza-con-pepperoni.jpg",4.0f,"Buenos Aires, Argentina"));
restauranteList.add(new Restaurante("Restaurant 25 de Mayo","https://placeralplato.com/files/2016/01/Pizza-con-pepperoni.jpg",3.0f,"San Miguel, Argentina"));
restauranteList.add(new Restaurante("Panquequeria Lo de Carlitos","https://placeralplato.com/files/2016/01/Pizza-con-pepperoni.jpg",4.0f,"Villa Gesell, Argentina"));
restauranteList.add(new Restaurante("FastFood McDonald`s","https://placeralplato.com/files/2016/01/Pizza-con-pepperoni.jpg",2.0f,"Ezeiza, Argentina"));
//asociamos recyclerview al adaptador
adapterRestaurantes =(new MyRestauranteRecyclerViewAdapter(restauranteList, mListener));
recyclerView.setAdapter(adapterRestaurantes);
}
return v;
}
ты можешь использовать следующий пример:
public void onBindViewHolder(@NonNull PersonViewHolder holder, int position){
holder.txtTitle.setText(modelResultsFilter.get(position).getTilte());
holder.txtDetail.setText(modelResultsFilter.get(position).getDescription());
PicassoTrustAll.getInstance(holder.itemView.getContext()).load(modelResultsFilter.get(position).getUrl_img()).into(holder.img_profile);
}
С названный в mГ©todo PicassoTrustAll.getInstance .
Если в твоем adapter ты посылаешь список объектов Restaurante
, которых restauranteList
:
adapterRestaurantes =(new MyRestauranteRecyclerViewAdapter(restauranteList, mListener));
В твоем adapter deberГ-схвати мочь показывать изображение как это ты реализуешь:
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.mItem = mValues.get(position);
...
...
Picasso.get().load(holder.mItem.getUrlPhoto()).into(holder.imageViewPhotoRestaurante);
...
...
}
Две причины, из-за которых ты не загружаешь изображение:
1) ImageView
, названный imageViewPhotoRestaurante
, на который ссылаются, не существует в том же layout.) Мне кажется
2, что твоя главная проблема просто, ты не считаешь определенным разрешение для того, чтобы ты aplicaciГіn он смог присоединяться в Интернет, это определи внутри тебя AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />