PialKanti

ReadListAdapter

Feb 14th, 2016
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. package com.example.pial_pc.instantbookreview;
  2.  
  3. import android.app.Activity;
  4. import android.content.Context;
  5. import android.graphics.Bitmap;
  6. import android.graphics.BitmapFactory;
  7. import android.graphics.drawable.BitmapDrawable;
  8. import android.util.Log;
  9. import android.view.LayoutInflater;
  10. import android.view.View;
  11. import android.view.ViewGroup;
  12. import android.widget.ArrayAdapter;
  13. import android.widget.Button;
  14. import android.widget.ImageButton;
  15. import android.widget.ImageView;
  16. import android.widget.TextView;
  17.  
  18. import java.util.ArrayList;
  19. import java.util.List;
  20.  
  21. /**
  22. * Created by Pial-PC on 2/12/2016.
  23. */
  24. public class ReadListAdapter extends ArrayAdapter<String[]> {
  25. Activity context;
  26. List<String[]> bookDetails;
  27. ImageView image1;
  28. TextView text1,isbn1,empty;
  29. Button moreButton1;
  30. ImageButton closeButton1;
  31. Bitmap bitmap1;
  32. BitmapDrawable bit1;
  33.  
  34.  
  35. public ReadListAdapter(Activity context, List<String[]> bookDetails) {
  36. super(context, R.layout.readlist_row);
  37. this.context=context;
  38. this.bookDetails = bookDetails;
  39. }
  40.  
  41. @Override
  42. public View getView(int position, View convertView, ViewGroup parent) {
  43. LayoutInflater inflater = context.getLayoutInflater();
  44. View view = inflater.inflate(R.layout.readlist_row, null, false);
  45. empty=(TextView)view.findViewById(R.id.EmptyReadList);
  46. image1=(ImageView)view.findViewById(R.id.image1);
  47.  
  48. text1=(TextView)view.findViewById(R.id.text1);
  49.  
  50. isbn1=(TextView)view.findViewById(R.id.isbn1);
  51.  
  52. moreButton1=(Button)view.findViewById(R.id.moreButton1);
  53. closeButton1=(ImageButton)view.findViewById(R.id.closeButton1);
  54.  
  55. if(bookDetails.isEmpty()){
  56. empty.setText("No books are in the List.");
  57. }else{
  58. empty.setVisibility(View.GONE);
  59. String info[] = bookDetails.get(position);
  60. text1.setText(info[1]);
  61. Log.i("PiAL", info[1]);
  62. isbn1.setText(info[0]);
  63. Log.i("PiAL", info[0]);
  64. text1.setVisibility(View.VISIBLE);
  65. bitmap1 = BitmapFactory.decodeFile(info[2]);
  66.  
  67. Log.i("PiAL", info[2]);
  68. bit1 = new BitmapDrawable(context.getResources(), bitmap1);
  69. image1.setVisibility(View.VISIBLE);
  70. image1.setBackgroundDrawable(bit1);
  71. }
  72.  
  73.  
  74. return view;
  75. }
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment