Android Open Source - oec_android Star Fragment






From Project

Back to project page oec_android.

License

The source code is released under:

MIT License

If you think the Android project oec_android 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 com.biekerwebdesign.openexoplanetcatalogue;
/*w w w  .j  a  va2s  .  co  m*/
import android.app.Fragment;
import android.app.ListFragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

import com.biekerwebdesign.beans.*;
import com.biekerwebdesign.beans.System;
import com.biekerwebdesign.xml.XMLPullParserStar;
import com.biekerwebdesign.xml.XMLPullParserSystem;

import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Bieker on 12/6/13.
 */
public class StarFragment extends ListFragment {

    private ListView listView;
    private XMLPullParserStar parser;
    private List<Star> stars;
    private ArrayAdapter<Star> adapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.star_list_fragment, container, false);
        Log.i("Fragment", "OnCreateView(): Star View Created");
        return view;
    }

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

        listView = (ListView) getView().findViewById(android.R.id.list); //Should be the list in star_list_fragment
        stars = new ArrayList<Star>();

        List<Star> stars = null;
        try {
            XMLPullParserStar parser = new XMLPullParserStar();
            stars = parser.parse(getActivity().getAssets().open("11 Com.xml"));
            Log.i("Parser:", "Star Assets Opened");
            ArrayAdapter<Star> adapter =
                    new ArrayAdapter<Star>(this.getActivity(), R.layout.list_item, stars);
            listView.setAdapter(adapter);
            Log.i("Adapter:", "Star ArrayAdapter Set");
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XmlPullParserException x) {
            x.printStackTrace();
        }
    }

    public void onListItemClicked(ListView l, View v, int position, long id) {
        //TODO Call to create Planet Fragment when Item clicked
        super.onListItemClick(l, v, position, id);
    }
}




Java Source Code List

com.biekerwebdesign.beans.Planet.java
com.biekerwebdesign.beans.Star.java
com.biekerwebdesign.beans.System.java
com.biekerwebdesign.openexoplanetcatalogue.MainActivity.java
com.biekerwebdesign.openexoplanetcatalogue.PlanetActivity.java
com.biekerwebdesign.openexoplanetcatalogue.PlanetFragment.java
com.biekerwebdesign.openexoplanetcatalogue.StarActivity.java
com.biekerwebdesign.openexoplanetcatalogue.StarFragment.java
com.biekerwebdesign.openexoplanetcatalogue.SystemActivity.java
com.biekerwebdesign.openexoplanetcatalogue.SystemFragment.java
com.biekerwebdesign.settings.SettingsActivity.java
com.biekerwebdesign.settings.SettingsFragment.java
com.biekerwebdesign.xml.XMLPullParserPlanet.java
com.biekerwebdesign.xml.XMLPullParserStar.java
com.biekerwebdesign.xml.XMLPullParserSystem.java