Guest User

Untitled

a guest
Jan 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. import android.app.Activity;
  2. import android.content.Context;
  3. import android.view.LayoutInflater;
  4. import android.view.View;
  5. import android.view.ViewGroup;
  6. import android.widget.ArrayAdapter;
  7. import android.widget.TextView;
  8. import org.npci.upi.security.pinactivitycomponent.R;
  9.  
  10. import java.util.ArrayList;
  11. import java.util.List;
  12.  
  13. public class SelectVPAAdpt extends ArrayAdapter<String> {
  14.  
  15. private ArrayList<String> vpaList;
  16.  
  17. Context mContext;
  18. LayoutInflater mInflater;
  19.  
  20.  
  21. public SelectVPAAdpt(List<String> vpaList, Context applicationContext) {
  22. super(applicationContext, R.layout.item_select_vpa_adpt, vpaList);
  23. }
  24.  
  25. // View lookup cache
  26. private static class ViewHolder {
  27. TextView txtVPAID;
  28. }
  29.  
  30. public SelectVPAAdpt(ArrayList<String> data, Context context) {
  31. super(context, R.layout.item_select_vpa_adpt, data);
  32. this.vpaList = data;
  33. this.mContext=context;
  34. this.mInflater = (LayoutInflater) getContext().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
  35. }
  36.  
  37. @Override
  38. public View getView(final int position, View view, ViewGroup parent) {
  39.  
  40. String account = vpaList.get(position);
  41. // Check if an existing view is being reused, otherwise inflate the view
  42. ViewHolder viewHolder;
  43.  
  44. if (view == null) {
  45. view = mInflater.inflate(R.layout.item_select_vpa_adpt, parent, false);
  46. viewHolder = new ViewHolder(); // view lookup cache stored in tag
  47. viewHolder.txtVPAID = (TextRobotoRegularFont) view.findViewById(R.id.txtVPAID);
  48. view.setTag(viewHolder);
  49. } else {
  50. viewHolder = (ViewHolder) view.getTag();
  51. }
  52.  
  53. viewHolder.txtVPAID.setText(account);
  54.  
  55. return view;
  56. }
  57. }
Add Comment
Please, Sign In to add comment