Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. public class Product implements Serializable{
  2.  
  3. public int id;
  4. public String Name;
  5. public String description;
  6. public String longDescription;
  7. public String amount;
  8. public String image;
  9. }
  10.  
  11. public class ProductPagerAdapter extends FragmentPagerAdapter {
  12.  
  13. private Context context;
  14. private ArrayList<Product> list;
  15.  
  16. public ProductPagerAdapter(FragmentManager fm, Context context, ArrayList<Product> list) {
  17. super(fm);
  18. this.context = context;
  19. this.list = list;
  20. }
  21.  
  22. @Override
  23. public Fragment getItem(int position) {
  24. return ProductFragment.newInstance(position);
  25. }
  26.  
  27. @Override
  28. public int getCount() {
  29. return list.size();
  30. }
  31. }
  32.  
  33. public class ProductFragment extends Fragment {
  34.  
  35. public ProductFragment() {
  36. // Required empty public constructor
  37. }
  38.  
  39. @Override
  40. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  41. Bundle savedInstanceState) {
  42. // Inflate the layout for this fragment
  43.  
  44. View v = inflater.inflate(R.layout.fragment_product, container, false);
  45.  
  46. //findViewById...
  47.  
  48. return v;
  49. }
  50.  
  51. public static Fragment newInstance(int id) {
  52. Bundle args = new Bundle();
  53. args.putInt("Id", id);
  54. ProductFragment fragment = new ProductFragment();
  55. fragment.setArguments(args);
  56. return fragment;
  57. }
  58. }
  59.  
  60. lv_itemRateList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  61. @Override
  62. public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
  63. Intent intent = new Intent(getActivity(), DetailsActivity.class);
  64. Product r = new Product();
  65. r = rateListArrayList.get(i);
  66. intent.putExtra("product",r);
  67. startActivity(intent);
  68. }
  69. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement