Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static final String STATE_SELECTED_NAVIGATION_ITEM = "selected_navigation_item";
- ListViewHollyLV;
- ListViewBollyLV;
- ListViewKollyLV;
- private void ListCreater()
- {
- HollyLV = (ListView)findViewById(R.id.bollyListView1);
- newMovieListActivity().CurrentLV = (ListView)findViewById(R.id.bollyListView1);
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_all_movies);
- ListCreater();
- // Set up the action bar to show tabs.
- finalActionBaractionBar = getActionBar();
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
- // for each of the sections in the app, add a tab to the action bar.
- Tab tab = actionBar.newTab().setText(R.string.hello_world).setTabListener(new TabListener( this, "holly", MovieListActivity.class));
- actionBar.addTab(tab);
- tab = actionBar.newTab().setText(R.string.hello_world).setTabListener(new TabListener( this, "bolly", Fragi2.class));
- actionBar.addTab(tab);
- }
- static class TabListener implements ActionBar.TabListener {
- private Fragment mFragment;
- private final Activity mActivity;
- private final String mTag;
- private final Class mClass;
- /** Constructor used each time a new tab is created.
- * * @paramactivity The host Activity, used to instantiate the fragment
- * * @paramtag The identifier tag for the fragment
- * * @paramclz The fragment's Class, used to instantiate the fragment
- * */
- publicTabListener(Activity activity, String tag, Class clz)
- { mActivity = activity;
- mTag = tag;
- mClass = clz; }
- /* The following are each of the ActionBar.TabListener callbacks */
- public void onTabSelected(Tab tab, FragmentTransactionft) {
- // Check if the fragment is already initialized
- if (mFragment == null) {
- // If not, instantiate and add it to the activity
- mFragment = Fragment.instantiate(mActivity, mClass.getName());
- ft.add(R.id.fragmentCnt, mFragment, mTag);
- }
- else {
- // If it exists, simply attach it in order to show it
- ft.attach(mFragment);
- }
- }
- public void onTabUnselected(Tab tab, FragmentTransactionft)
- {
- if (mFragment != null) {
- // Detach the fragment, because another one is being attached
- ft.detach(mFragment);
- }
- }
- public void onTabReselected(Tab tab, FragmentTransactionft) {
- // User selected the already selected tab. Usually do nothing.
- }
- }
- //This fragment is used for “holly” tab
- public static class MovieListActivity extends Fragment {
- ListViewCurrentLV;
- @Override
- public View onCreateView(LayoutInflaterinflater, ViewGroup container,
- Bundle savedInstanceState){
- // Inflate the menu; this adds items to the action bar if it is present.
- View V = inflater.inflate(R.layout.activity_frag1, container, false);
- ManageMovieList.MakeList(); // Makes separate list of Hollywood and bollywood //movies
- LoadMovieList();
- return V;
- }
- @Override
- public void onPause() {
- super.onPause();
- }
- //Loads the Hollywood movie list to the listview using custom adapter
- private void LoadMovieList()
- {
- ManageMovieList.HollywoodMovieAdapter(getActivity(), CurrentLV);
- }
- }
- /// Dummy Fragment class (was created while trying tabbed layout) which contains only ///textview. Still this fragment is used for “bolly” tab
- public static class Fragi1 extends Fragment {
- @Override
- public View onCreateView(LayoutInflaterinflater, ViewGroup container,
- Bundle savedInstanceState){
- // Inflate the menu; this adds items to the action bar if it is present.
- View V = inflater.inflate(R.layout.activity_frag1, container, false);
- return V;
- }
- }
- private final Context context;
- ArrayList<Movie> _Movies ;
- static final String REVIEW = "com.example.ticketonline";
- publicCustomMovieArrayAdapter(Context context, ArrayList<Movie>movieItems) {
- super(context, R.layout.movie_list_item, movieItems);
- this.context = context;
- _Movies = movieItems;
- Movie currentMovie = new Movie();
- ArrayList<Movie> _Movies ;
- }
- String Title;
- String category;
- int Id;
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- LayoutInflaterinflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- if (convertView == null) {
- convertView = inflater.inflate(R.layout.movie_list_item, parent, false);
- TextViewtextName = (TextView) convertView.findViewById(R.id.textViewMovieName);
- TextViewtextCate = (TextView) convertView.findViewById(R.id.textViewMovieCategory);
- ImageViewimageView = (ImageView) convertView.findViewById(R.id.imageViewMoviePoster);
- Button btn = (Button)convertView.findViewById(R.id.buttonSelectMovie);
- textName.setText(_Movies.get(position).GetMovieName(position));
- textCate.setText(_Movies.get(position).GetMovieCategory(position));
- imageView.setImageResource(_Movies.get(position).GetMoviePosterID(position));
- finalint p = position;
- btn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(context, ReviewAndBook.class);
- intent.putExtra(REVIEW, Movie.GetMovieReview(p));
- intent.putExtra(android.content.Intent.EXTRA_TEXT, Movie.GetMovieDirector(p));
- intent.putExtra(android.content.Intent.EXTRA_SUBJECT, Movie.GetMovieCast(p));
- context.startActivity(intent);
- }
- });
- }
- returnconvertView;
- }
- public static void HollywoodMovieAdapter(Context cnt,ListViewmovieListUI)
- {
- //ListViewmovieListUI = (ListView)findViewById(R.id.movieListView);
- ArrayList<Movie> _hollywoodMovies = ManageMovieList.RecentMovies_Holly;
- movieListUI.setAdapter( new CustomMovieArrayAdapter(cnt, _hollywoodMovies));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement