Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.k.cal.fragment;
- import me.k.cal.R;
- import me.k.cal.struct.WLEvent;
- import android.app.Fragment;
- import android.os.Bundle;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.ListView;
- public class EventDisplayFragment extends Fragment
- {
- private WLEvent[] m_events;
- @Override
- public void onSaveInstanceState(Bundle p_state)
- {
- if(m_events != null)
- p_state.putParcelableArray("EVENTS", m_events);
- }
- @Override
- public View onCreateView(LayoutInflater p_inflater, ViewGroup p_container, Bundle p_prev_state)
- {
- return p_inflater.inflate(R.layout.fragment_main, p_container, false);
- }
- @Override
- public void onActivityCreated(Bundle p_prev_state)
- {
- super.onActivityCreated(p_prev_state);
- if(p_prev_state != null && p_prev_state.containsKey("EVENTS"))
- m_events = (WLEvent[])p_prev_state.getParcelableArray("EVENTS");
- }
- public int getIndex()
- {
- try
- {
- return this.getListView().getFirstVisiblePosition();
- }
- catch(Exception e){ return 0; }
- }
- public int getTop()
- {
- try
- {
- return this.getListView().getChildAt(0).getTop();
- }
- catch(Exception e){ return 0; }
- }
- public void setListViewPos(int p_ind, int p_top)
- {
- if(this.getListView().getCount() != 0)
- this.getListView().setSelectionFromTop(p_ind, p_top);
- }
- public void setEvents(WLEvent[] p_events)
- {
- m_events = p_events;
- }
- public WLEvent[] getEvents()
- {
- return m_events;
- }
- private ListView getListView()
- {
- return (ListView)getView().findViewById(R.id.main_events);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment