Java tutorial
/* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.starim.android.apps.travelplanner; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.GridView; public class TravelItemTransitionFragment extends Fragment { private static final String TAG = "TravelItemTransitionFragment"; private TravelItemCategoryAdapter mAdapter; public static TravelItemTransitionFragment newInstance() { return new TravelItemTransitionFragment(); } public TravelItemTransitionFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // This is the adapter we use to populate the grid. mAdapter = new TravelItemCategoryAdapter(inflater, R.layout.fragment_travelitem_grid); // Inflate the layout with a GridView in it. return inflater.inflate(R.layout.fragment_travelitem_transition, container, false); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { GridView grid = (GridView) view.findViewById(R.id.grid); grid.setAdapter(mAdapter); } @Override public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) { return AnimationUtils.loadAnimation(getActivity(), enter ? android.R.anim.fade_in : android.R.anim.fade_out); } }