el código que tengo es así:
en el fragment de la agenda (el que se llama desde el mainActivity al pulsar en la opción de menu agenda)
Código:
el de uno de los fragment de los tabs:public class AgendaFragment extends SherlockFragment { View fragment; MainActivity mActivity; ActionBar actionBar; Tab tab; public static AgendaFragment newInstance() { AgendaFragment mFragment = new AgendaFragment(); return mFragment; } @Override public void onStart() { super.onStart(); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mActivity = (MainActivity) getActivity(); actionBar = mActivity.getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); tab = actionBar.newTab().setTabListener(new EventosFuturosFragment()); tab.setText(mActivity.getResources().getString(R.string.tab_eventos)); actionBar.addTab(tab); tab = actionBar.newTab().setTabListener(new EventosPasadosFragment()); tab.setText(mActivity.getResources().getString(R.string.tab_eventos_pasados)); actionBar.addTab(tab); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { fragment = inflater.inflate(R.layout.list, null); setHasOptionsMenu(true); return fragment; } @Override public void onResume() { super.onResume(); } @Override public void onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu, com.actionbarsherlock.view.MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); menu.clear(); } @Override public boolean onOptionsItemSelected( com.actionbarsherlock.view.MenuItem item) { return super.onOptionsItemSelected(item); } }
Código:
Me haríais feliz diciéndome como podría solucionar esto...public class EventosPasadosFragment extends SherlockFragment implements ActionBar.TabListener{ private Fragment mFragment; View fragment; ListView lv; ProgressDialog dialog; MainActivity mActivity; RequestQueue mRequestQueue; EventoAdapter eventoAdapter; ArrayList<Evento> items; String url; public static EventosPasadosFragment newInstance() { EventosPasadosFragment mFragment = new EventosPasadosFragment(); return mFragment; } @Override public void onStart() { super.onStart(); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mActivity = (MainActivity) getActivity(); eventoAdapter = new EventoAdapter(this.getActivity()); items = new ArrayList<Evento>(); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { fragment = inflater.inflate(R.layout.list, null); setHasOptionsMenu(true); lv = (ListView) fragment.findViewById(R.id.item_list); lv.setAdapter(eventoAdapter); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { } }); mRequestQueue = Volley.newRequestQueue(this.getActivity() .getApplicationContext()); obtenerEventos(); return fragment; } @Override public void onResume() { super.onResume(); } @Override public void onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu, com.actionbarsherlock.view.MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); menu.clear(); } @Override public boolean onOptionsItemSelected( com.actionbarsherlock.view.MenuItem item) { return super.onOptionsItemSelected(item); } public void onTabSelected(Tab tab, FragmentTransaction ft) { mFragment = new EventosPasadosFragment(); ft.add(android.R.id.content, mFragment); ft.attach(mFragment); } public void onTabUnselected(Tab tab, FragmentTransaction ft) { ft.remove(mFragment); } public void onTabReselected(Tab tab, FragmentTransaction ft) { }
Gracias de antemano!