Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.22 KB | None | 0 0
  1. private static final String STATE_SELECTED_NAVIGATION_ITEM = "selected_navigation_item";
  2. ListViewHollyLV;
  3. ListViewBollyLV;
  4. ListViewKollyLV;
  5.  
  6. private void ListCreater()
  7. {
  8. HollyLV = (ListView)findViewById(R.id.bollyListView1);
  9. newMovieListActivity().CurrentLV = (ListView)findViewById(R.id.bollyListView1);
  10. }
  11.  
  12.  
  13. @Override
  14. protected void onCreate(Bundle savedInstanceState) {
  15.  
  16. super.onCreate(savedInstanceState);
  17. setContentView(R.layout.activity_all_movies);
  18.  
  19. ListCreater();
  20.  
  21.  
  22. // Set up the action bar to show tabs.
  23. finalActionBaractionBar = getActionBar();
  24. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  25.  
  26. // for each of the sections in the app, add a tab to the action bar.
  27. Tab tab = actionBar.newTab().setText(R.string.hello_world).setTabListener(new TabListener( this, "holly", MovieListActivity.class));
  28. actionBar.addTab(tab);
  29. tab = actionBar.newTab().setText(R.string.hello_world).setTabListener(new TabListener( this, "bolly", Fragi2.class));
  30. actionBar.addTab(tab);
  31. }
  32.  
  33.  
  34. static class TabListener implements ActionBar.TabListener {
  35. private Fragment mFragment;
  36. private final Activity mActivity;
  37. private final String mTag;
  38. private final Class mClass;
  39.  
  40. /** Constructor used each time a new tab is created.
  41. * * @paramactivity The host Activity, used to instantiate the fragment
  42. * * @paramtag The identifier tag for the fragment
  43. * * @paramclz The fragment's Class, used to instantiate the fragment
  44. * */
  45.  
  46. publicTabListener(Activity activity, String tag, Class clz)
  47. { mActivity = activity;
  48. mTag = tag;
  49. mClass = clz; }
  50.  
  51. /* The following are each of the ActionBar.TabListener callbacks */
  52.  
  53. public void onTabSelected(Tab tab, FragmentTransactionft) {
  54. // Check if the fragment is already initialized
  55. if (mFragment == null) {
  56. // If not, instantiate and add it to the activity
  57. mFragment = Fragment.instantiate(mActivity, mClass.getName());
  58. ft.add(R.id.fragmentCnt, mFragment, mTag);
  59. }
  60. else {
  61. // If it exists, simply attach it in order to show it
  62. ft.attach(mFragment);
  63. }
  64. }
  65. public void onTabUnselected(Tab tab, FragmentTransactionft)
  66. {
  67. if (mFragment != null) {
  68. // Detach the fragment, because another one is being attached
  69. ft.detach(mFragment);
  70. }
  71. }
  72. public void onTabReselected(Tab tab, FragmentTransactionft) {
  73. // User selected the already selected tab. Usually do nothing.
  74. }
  75. }
  76.  
  77. //This fragment is used for “holly” tab
  78. public static class MovieListActivity extends Fragment {
  79.  
  80. ListViewCurrentLV;
  81.  
  82.  
  83. @Override
  84. public View onCreateView(LayoutInflaterinflater, ViewGroup container,
  85. Bundle savedInstanceState){
  86. // Inflate the menu; this adds items to the action bar if it is present.
  87. View V = inflater.inflate(R.layout.activity_frag1, container, false);
  88. ManageMovieList.MakeList(); // Makes separate list of Hollywood and bollywood //movies
  89. LoadMovieList();
  90.  
  91. return V;
  92.  
  93. }
  94.  
  95. @Override
  96. public void onPause() {
  97. super.onPause();
  98.  
  99. }
  100. //Loads the Hollywood movie list to the listview using custom adapter
  101. private void LoadMovieList()
  102. {
  103. ManageMovieList.HollywoodMovieAdapter(getActivity(), CurrentLV);
  104. }
  105. }
  106.  
  107. /// Dummy Fragment class (was created while trying tabbed layout) which contains only ///textview. Still this fragment is used for “bolly” tab
  108.  
  109. public static class Fragi1 extends Fragment {
  110.  
  111.  
  112. @Override
  113. public View onCreateView(LayoutInflaterinflater, ViewGroup container,
  114. Bundle savedInstanceState){
  115. // Inflate the menu; this adds items to the action bar if it is present.
  116. View V = inflater.inflate(R.layout.activity_frag1, container, false);
  117.  
  118. return V;
  119.  
  120. }
  121. }
  122.  
  123. private final Context context;
  124. ArrayList<Movie> _Movies ;
  125. static final String REVIEW = "com.example.ticketonline";
  126.  
  127.  
  128. publicCustomMovieArrayAdapter(Context context, ArrayList<Movie>movieItems) {
  129. super(context, R.layout.movie_list_item, movieItems);
  130. this.context = context;
  131. _Movies = movieItems;
  132. Movie currentMovie = new Movie();
  133. ArrayList<Movie> _Movies ;
  134. }
  135.  
  136. String Title;
  137. String category;
  138. int Id;
  139.  
  140. @Override
  141. public View getView(int position, View convertView, ViewGroup parent) {
  142.  
  143. LayoutInflaterinflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  144.  
  145. if (convertView == null) {
  146. convertView = inflater.inflate(R.layout.movie_list_item, parent, false);
  147.  
  148. TextViewtextName = (TextView) convertView.findViewById(R.id.textViewMovieName);
  149. TextViewtextCate = (TextView) convertView.findViewById(R.id.textViewMovieCategory);
  150. ImageViewimageView = (ImageView) convertView.findViewById(R.id.imageViewMoviePoster);
  151. Button btn = (Button)convertView.findViewById(R.id.buttonSelectMovie);
  152.  
  153. textName.setText(_Movies.get(position).GetMovieName(position));
  154. textCate.setText(_Movies.get(position).GetMovieCategory(position));
  155. imageView.setImageResource(_Movies.get(position).GetMoviePosterID(position));
  156.  
  157. finalint p = position;
  158. btn.setOnClickListener(new View.OnClickListener() {
  159. @Override
  160. public void onClick(View v) {
  161. Intent intent = new Intent(context, ReviewAndBook.class);
  162. intent.putExtra(REVIEW, Movie.GetMovieReview(p));
  163. intent.putExtra(android.content.Intent.EXTRA_TEXT, Movie.GetMovieDirector(p));
  164. intent.putExtra(android.content.Intent.EXTRA_SUBJECT, Movie.GetMovieCast(p));
  165. context.startActivity(intent);
  166. }
  167.  
  168. });
  169.  
  170. }
  171.  
  172. returnconvertView;
  173. }
  174.  
  175. public static void HollywoodMovieAdapter(Context cnt,ListViewmovieListUI)
  176. {
  177. //ListViewmovieListUI = (ListView)findViewById(R.id.movieListView);
  178. ArrayList<Movie> _hollywoodMovies = ManageMovieList.RecentMovies_Holly;
  179. movieListUI.setAdapter( new CustomMovieArrayAdapter(cnt, _hollywoodMovies));
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement