Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. Incompatible types
  2. Required: android.support.v4.app.Fragment
  3. Found: ourpackagename.fragment_slides
  4.  
  5. import android.content.Context;
  6. import android.content.res.Resources;
  7. import android.os.Bundle;
  8. import android.support.v4.app.Fragment;
  9. import android.support.v4.app.FragmentManager;
  10. import android.support.v4.app.FragmentPagerAdapter;
  11.  
  12. public class SlidesPageAdaptor extends FragmentPagerAdapter {
  13.  
  14. String[] devices;
  15. String[] deviceDescription;
  16.  
  17. public SlidesPageAdaptor(FragmentManager fm, Context context) {
  18. super(fm);
  19.  
  20. Resources resources = context.getResources();
  21.  
  22. devices = resources.getStringArray(R.array.devices);
  23. deviceDescription = resources.getStringArray(R.array.device_description);
  24. }
  25.  
  26. @Override
  27. public Fragment getItem(int position) {
  28.  
  29. Bundle bundle = new Bundle();
  30. bundle.putString(fragment_slides.DescriptionKey, deviceDescription[position]);
  31. bundle.putInt(fragment_slides.ImageIDKey, getImageID(position));
  32.  
  33. fragment_slides fragmentSlide = new fragment_slides();
  34. fragmentSlide.setArguments(bundle);
  35.  
  36. return fragmentSlide;
  37. }
  38.  
  39. private int getImageID(int position) {
  40.  
  41. int id = 0;
  42. switch (position)
  43. {
  44. case 0:
  45. id = R.drawable.abc_btn_check_material;
  46. break;
  47. case 1:
  48. id = R.drawable.abc_ab_share_pack_mtrl_alpha;
  49. break;
  50. case 2:
  51. id = R.drawable.abc_btn_radio_material;
  52. break;
  53. }
  54.  
  55. return id;
  56. }
  57.  
  58. @Override
  59. public CharSequence getPageTitle(int position) {
  60. return devices[position];
  61. }
  62.  
  63. @Override
  64. public int getCount() {
  65. return devices.length;
  66. }
  67.  
  68. import android.app.Activity;
  69. import android.net.Uri;
  70. import android.os.Bundle;
  71. import android.app.Fragment;
  72. import android.view.LayoutInflater;
  73. import android.view.View;
  74. import android.view.ViewGroup;
  75. import android.widget.ImageView;
  76. import android.widget.TextView;
  77.  
  78. public class fragment_slides extends Fragment {
  79.  
  80. public static final String ImageIDKey = "imagekey";
  81. public static final String DescriptionKey = "descriptionkey";
  82.  
  83. public fragment_slides() {
  84. // Required empty public constructor
  85. }
  86.  
  87. @Override
  88. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  89.  
  90. // Inflate the layout for this fragment
  91.  
  92. View view = inflater.inflate(R.layout.fragment_slides_images, container, false);
  93.  
  94. Bundle bundle = getArguments();
  95.  
  96. if(bundle != null)
  97. {
  98. int imageID = bundle.getInt(ImageIDKey);
  99. String description = bundle.getString(DescriptionKey);
  100.  
  101. setValues(view, imageID, description);
  102. }
  103.  
  104. return view;
  105.  
  106. //return inflater.inflate(R.layout.fragment_slides_images, container, false);
  107. }
  108.  
  109. private void setValues(View view, int imageID, String description) {
  110. ImageView imageview = (ImageView) view.findViewById(R.id.imageViewSlide);
  111. imageview.setImageResource(imageID);
  112.  
  113. TextView textView = (TextView) view.findViewById(R.id.tvSlideTest);
  114. textView.setText(description);
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement