Advertisement
Guest User

Untitled

a guest
May 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. package com.example.juniorsantos.barberapp.Adapter;
  2.  
  3. import android.content.Context;
  4. import android.support.annotation.LayoutRes;
  5. import android.support.annotation.NonNull;
  6. import android.support.annotation.Nullable;
  7. import android.view.LayoutInflater;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10. import android.widget.ArrayAdapter;
  11. import android.widget.TextView;
  12.  
  13. import com.example.juniorsantos.barberapp.Entidades.Produtos;
  14. import com.example.juniorsantos.barberapp.R;
  15.  
  16. import java.util.ArrayList;
  17.  
  18.  
  19.  
  20. /**
  21. * Created by Daniel Lopes on 23/06/2017.
  22. */
  23.  
  24. public class ProdutosAdapter extends ArrayAdapter<Produtos> {
  25.  
  26. private ArrayList<Produtos> produto;
  27. private Context context;
  28.  
  29. public ProdutosAdapter(Context c, ArrayList<Produtos> objects) {
  30. super(c, 0, objects);
  31.  
  32. this.context = c;
  33. this.produto = objects;
  34. }
  35.  
  36.  
  37. @Override
  38. public View getView(int position, View convertView, ViewGroup parent) {
  39.  
  40. View view = null;
  41.  
  42. if (produto != null) {
  43. LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
  44.  
  45. view = inflater.inflate(R.layout.lista_produtos, parent, false);
  46.  
  47. TextView textViewNome = (TextView) view.findViewById(R.id.textViewNome);
  48. TextView textViewValor = (TextView) view.findViewById(R.id.textViewValor);
  49.  
  50. Produtos produtos2 = produto.get(position);
  51. textViewNome.setText(produtos2.getNome());
  52. textViewValor.setText(produtos2.getValor().toString());
  53.  
  54. }
  55.  
  56. return view;
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement