Android Open Source - musicpractice Song Detail Fragment






From Project

Back to project page musicpractice.

License

The source code is released under:

Apache License

If you think the Android project musicpractice listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package us.marsware.musicpractice;
/*  w w w . j a  v a  2 s. c o m*/
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import us.marsware.musicpractice.Util.SongContent;

/**
 * A fragment representing a single Song detail screen.
 * This fragment is either contained in a {@link SongListActivity}
 * in two-pane mode (on tablets) or a {@link SongDetailActivity}
 * on handsets.
 */
public class SongDetailFragment extends Fragment {
    /**
     * The fragment argument representing the item ID that this fragment
     * represents.
     */
    public static final String ARG_ITEM_ID = "item_id";

    /**
     * The dummy content this fragment is presenting.
     */
    private SongContent.SongItem mItem;

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public SongDetailFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (getArguments().containsKey(ARG_ITEM_ID)) {
            // Load the dummy content specified by the fragment
            // arguments. In a real-world scenario, use a Loader
            // to load content from a content provider.
            mItem = SongContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_song_detail, container, false);

        // Show the dummy content as text in a TextView.
        if (mItem != null) {
            ((TextView) rootView.findViewById(R.id.partText)).setText(mItem.part);
            ((TextView) rootView.findViewById(R.id.songText)).setText(mItem.title);
            ((TextView) rootView.findViewById(R.id.arrText)).setText(mItem.arranger);
            //((ImageView) rootView.findViewById(R.id.partText)).setText(mItem.part);
            //((TextView) rootView.findViewById(R.id.timeSig)).setText(mItem.timeSig);
            //((TextView) rootView.findViewById(R.id.keySig)).setText(mItem.keySig);
            //((TextView) rootView.findViewById(R.id.bpmText)).setText(mItem.bpm);
            
        }

        return rootView;
    }
}




Java Source Code List

us.marsware.musicpractice.SongDetailActivity.java
us.marsware.musicpractice.SongDetailFragment.java
us.marsware.musicpractice.SongListActivity.java
us.marsware.musicpractice.SongListFragment.java
us.marsware.musicpractice.Util.SongContent.java