how to click the popwindow in the actionbar? - android

I have created action bar.in that when i click on one of the menu a pop window should be displayed.I have done that.But after the pop up window displays i am not able to perform other function in my action bar.howw can i acheive that.I have posted my code.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onTabSelected(Tab tab, FragmentTransaction ft) {
mDisplayMode = tab.getPosition();
System.out.println("text");
// Do stuff based on new tab selected
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// Do Nothing
}
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// Do nothing
}*/
ActionBar bar = getActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab tabA = bar.newTab().setText("Home");
ActionBar.Tab tabB = bar.newTab().setText("Listings");
ActionBar.Tab tabC = bar.newTab().setText("Remote");
Fragment fragmentA = new ATab();
Fragment fragmentB = new BTab();
Fragment fragmentC = new CTab();
bar.setDisplayShowHomeEnabled(true);
tabA.setTabListener(new MyTabsListener(fragmentA));
tabB.setTabListener(new MyTabsListener(fragmentB));
tabC.setTabListener(new MyTabsListener(fragmentC));
bar.addTab(tabA);
bar.addTab(tabB);
bar.addTab(tabC);
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.option, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.settings:
newGame();
return true;
case R.id.help:
// showHelp();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void newGame() {
LayoutInflater inflater = (LayoutInflater)
this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
PopupWindow pw = new PopupWindow(
inflater.inflate(R.layout.settings, null, true), 300, 600, true);
// The code below assumes that the root container has an id called 'main'
pw.showAtLocation(this.findViewById(R.id.settings), Gravity.RIGHT, 0, 0);
}
protected class MyTabsListener implements ActionBar.TabListener {
private Fragment mfragment;
public MyTabsListener(Fragment fragment) {
this.mfragment = fragment;
}
#Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
ft.add(R.id.fragment_place, mfragment, null);
}
#Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
#Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
ft.remove(mfragment);
}
}
}

Related

How to select previous tab which we have selected already in action bar?

here my problem ill explain.Initially first tab ill be selected and next if i click second tab, its work well but again click first tab my app ill be closed. could you suggest me for this.
here my code.
public class MainActivity extends Activity {
public static Context appContext;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
appContext = getApplicationContext();
ActionBar actionbar = getActionBar();
actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab connectionTab = actionbar.newTab().setText("Connection");
ActionBar.Tab masterDataTab = actionbar.newTab().setText("Master Data");
Fragment connection = new AFragment();
Fragment masterData = new BFragment();
connectionTab.setTabListener(new MyTabsListener(connection));
masterDataTab.setTabListener(new MyTabsListener(masterData));
actionbar.addTab(connectionTab);
actionbar.addTab(masterDataTab);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
}
return false;
}
#Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
}
}
class MyTabsListener implements ActionBar.TabListener {
public Fragment fragment;
public MyTabsListener(Fragment fragment) {
this.fragment = fragment;
}
#Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
Toast.makeText(MainActivity.appContext, "Reselected!", Toast.LENGTH_LONG).show();
//ft.replace(R.id.fragment_container, fragment);
}
#Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
ft.replace(R.id.fragment_container, fragment);
}
#Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
ft.remove(fragment);
}
}

Fragment is re created when ActionbarSherlock tab is selected

I have a Fragment Activity which holds three fragments.
public class MainActivity extends SherlockFragmentActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar bar = getSupportActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab tab1 = bar.newTab();
ActionBar.Tab tab2 = bar.newTab();
ActionBar.Tab tab3 = bar.newTab();
tab1.setText("");
tab1.setIcon(R.drawable.abs__ic_menu_share_holo_dark);
tab2.setText("");
tab2.setIcon(R.drawable.abs__ic_voice_search);
tab3.setText("");
tab3.setIcon(R.drawable.abs__ic_cab_done_holo_dark);
if (savedInstanceState == null) {
tab1.setTabListener(new MyTabListener());
tab2.setTabListener(new MyTabListener());
tab3.setTabListener(new MyTabListener());
bar.addTab(tab1);
bar.addTab(tab2);
bar.addTab(tab3);
}
}
private class MyTabListener implements ActionBar.TabListener {
#Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
switch (tab.getPosition()) {
case 0:
FeedsActivity frag = new FeedsActivity();
ft.replace(android.R.id.content, frag);
return;
case 1:
ProfileActivity frag2 = new ProfileActivity();
ft.replace(android.R.id.content, frag2);
return;
case 2:
MyMemoirsActivity frag3 = new MyMemoirsActivity();
ft.replace(android.R.id.content, frag3);
return;
}
}
#Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
#Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
}
}
And here is first Fragment,
public class FeedsActivity extends SherlockFragment {
public static String[] MainCategory;
public static String[] MainCategoryId;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup group,
Bundle saved) {
setRetainInstance(true);
return inflater.inflate(R.layout.activity_feeds, group, false);
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
new GetMainCategory(getActivity()).execute();
}
}
When I select second tab and then select first tab the async task in first fragment is called again.How can I retain state of first fragment so that its view is created once? I have used setRetainInstance(true) but didnt work.
I solved this issue by using show and hide instead of attach and detach.
private class MyTabListener implements ActionBar.TabListener {
#Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
switch (tab.getPosition()) {
case 0:
if (frag1 == null) {
// If not, instantiate and add it to the activity
frag1 = Fragment.instantiate(getApplicationContext(),
FeedsActivity.class.getName());
ft.add(android.R.id.content, frag1, "Feeds");
} else {
// If it exists, simply attach it in order to show it
ft.show(frag1);
}
return;
case 1:
if (frag2 == null) {
// If not, instantiate and add it to the activity
frag2 = Fragment.instantiate(getApplicationContext(),
ProfileActivity.class.getName());
ft.add(android.R.id.content, frag2, "Profile");
} else {
// If it exists, simply attach it in order to show it
ft.show(frag2);
}
return;
case 2:
if (frag3 == null) {
// If not, instantiate and add it to the activity
frag3 = Fragment.instantiate(getApplicationContext(),
History.class.getName());
ft.add(android.R.id.content, frag3, "History");
} else {
// If it exists, simply attach it in order to show it
ft.show(frag3);
}
return;
}
}
#Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
if (frag1 != null) {
// Detach the fragment, because another one is being attached
switch (tab.getPosition()) {
case 0:
ft.hide(frag1);
return;
case 1:
ft.hide(frag2);
return;
case 2:
ft.hide(frag3);
return;
}
}
}
#Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
}
The proper way to use TabListener is this :
#Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// Check if the fragment is already initialized
if (mFragment == null) {
// If not, instantiate and add it to the activity
mFragment = Fragment.instantiate(mActivity, mClass.getName());
ft.add(android.R.id.content, mFragment, mTag);
} else {
// If it exists, simply attach it in order to show it
ft.attach(mFragment);
}
}
#Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (mFragment != null) {
// Detach the fragment, because another one is being attached
ft.detach(mFragment);
}
}
#override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// User selected the already selected tab. Usually do nothing.
}
Basically you need to check if that's the first time when your Fragment is being initialised. If not, you should add it to your screen and when the user unselect a tab you should detach the current visible fragment and add the new one. That's the way it should work. You don't need to create a new instance of Fragment everytime user click the tab.

Not able to display fragment when menu item is clicked

I'm having a difficulty to show a fragment in a container when a menu item is clicked.Below is my code.
I tried to do ft.show(); inside onMenuItemClick of Login Menu Item but its not working and I don't know what am I doing wrong as I'm neither getting any errors nor the app is crashing. Fragments which are attached to the Tabs are working and displaying just fine. It's just that when I try to load a fragment in an container when menu item is clicked at that time nothing happens.Please point me in a right direction and lemme know what am I doing wrong.
public class HomeActivity extends SherlockFragmentActivity {
public SherlockFragment fragment;
FragmentTransaction ft;
public static Context appContext;
ActionBar actionbar;
String mCurFilter;
LoginScreenFragment loginFragment;
/** Called when the activity is first created. */
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
appContext = getApplicationContext();
actionbar = getSupportActionBar();
actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab HomeTab = actionbar.newTab().setText("Home");
ActionBar.Tab CartTab = actionbar.newTab().setText("Cart");
ActionBar.Tab myTab = actionbar.newTab().setText("MyFragment");
ActionBar.Tab moreTab = actionbar.newTab().setText("More...");
HomeFragment homeFragment = new HomeFragment();
CartFragment cartFragment = new CartFragment();
MyFragment myFragment = new MyFragment();
MoreFragment moreFragment = new MoreFragment();
loginFragment = new LoginScreenFragment();
HomeTab.setTabListener(new MyTabsListener(homeFragment));
CartTab.setTabListener(new MyTabsListener(cartFragment));
myTab.setTabListener(new MyTabsListener(myFragment));
moreTab.setTabListener(new MyTabsListener(moreFragment));
actionbar.addTab(HomeTab);
actionbar.addTab(CartTab);
actionbar.addTab(myTab);
actionbar.addTab(moreTab);
ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.fragment_container, homeFragment);
ft.show(homeFragment);
ft.add(R.id.fragment_container, cartFragment);
ft.hide(cartFragment);
ft.add(R.id.fragment_container, myFragment);
ft.hide(myFragment);
ft.add(R.id.fragment_container, moreFragment);
ft.hide(moreFragment);
ft.add(R.id.fragment_container, loginFragment);
ft.hide(loginFragment);
ft.commit();
}
#Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("tab", getSupportActionBar()
.getSelectedNavigationIndex());
System.out.println("onSaveInstanceState");
}
#Override
public boolean onCreateOptionsMenu(final Menu menu) {
MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
View searchView = SearchViewCompat.newSearchView(this);
if (searchView != null) {
SearchViewCompat.setOnQueryTextListener(searchView,
new OnQueryTextListenerCompat() {
#Override
public boolean onQueryTextChange(String newText) {
mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
return true;
}
});
item.setActionView(searchView);
}
MenuItem loginItem = menu.add("Login");
loginItem.setTitle("Login");
loginItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
loginItem.setOnMenuItemClickListener(new OnMenuItemClickListener(){
#Override
public boolean onMenuItemClick(MenuItem item) {
//I wanted to show "loginFragment" when the Login button is clicked.But unfortunately its not showing up.Also the application is not giving any errors or crashing
ft.show(loginFragment);
return false;
}
});
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.menuitem_home) {
Toast.makeText(appContext, "Home", Toast.LENGTH_SHORT).show();
return true;
} else if (itemId == R.id.menuitem_shop) {
Toast.makeText(appContext, "Shop", Toast.LENGTH_SHORT).show();
return true;
} else if (itemId == R.id.menuitem_cart) {
Toast.makeText(appContext, "Cart", Toast.LENGTH_SHORT).show();
return true;
} else if (itemId == R.id.menuitem_my) {
Toast.makeText(appContext, "My", Toast.LENGTH_SHORT).show();
return true;
} else if (itemId == R.id.menuitem_more) {
Toast.makeText(appContext, "More...", Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
static class MyTabsListener implements ActionBar.TabListener {
public SherlockFragment fragment;
public MyTabsListener(SherlockFragment fragment) {
this.fragment = fragment;
}
#Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
System.out.println("TabReselected " + tab.getPosition());
}
#Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
System.out.println("TabSelected " + tab.getPosition());
ft.show(this.fragment);
}
#Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
System.out.println("TabUnselected " + tab.getPosition());
ft.hide(this.fragment);
}
}
}
Instead of adding the fragments to one container and hiding & showing them you can try replacing fragments when you click on your menu buttons.
for ex- when you click on login button
ft.replace(R.id.fragment_container, loginFragment).commit();
give it a try hope it will work.
You should begin and commit the transaction again. Try:
#Override
public boolean onMenuItemClick(MenuItem item) {
ft = getSupportFragmentManager().beginTransaction();
ft.show(loginFragment);
ft.commit();
return false;
}

listviewselection in a listfragment in a tab

I have the following problem. I have an app with a viewpager and two tabs. The two tabs are two listfragments. Now I want that if the user selects an item in the first tab, that the 5th item is selected in the second tab. (the second tab is the translation of text from the first item). My problem is that when i select an item in the first tab, and now switch to the second tab, there is nothing selected.
When I click something in the first tab I call a function in the Parent activity which calls a function in the second fragment which should select the 5th Item.
This is the code of the Fragment activity:
public class Dailyquran extends FragmentActivity implements ActionBar.TabListener {
SectionsPagerAdapter mSectionsPagerAdapter;
ViewPager mViewPager;
public ArrayList<Tweet> tweets = new ArrayList<Tweet>();
public ArrayList<Tweet> tweets2 = new ArrayList<Tweet>();
//private static ArrayList<String> roomList;
public String a;
public static int laenge_inhalt;
public static int selected;
public static String sure_media;
public static String vers_media;
String koran_filename;
//int tabwahl=0;
int playstatus=0;
MediaPlayer mp = new MediaPlayer();
MenuItem playMenu;
#Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_dailyquran, menu);
playMenu = menu.findItem(R.id.menu_play);
return true;
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Daily Quran");
setContentView(R.layout.activity_dailyquran);
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the action bar.
final ActionBar actionBar = getActionBar();
// set the app icon as an action to go home
actionBar.setDisplayHomeAsUpEnabled(true);
//enable tabs in actionbar
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
// When swiping between different sections, select the corresponding tab.
// We can also use ActionBar.Tab#select() to do this if we have a reference to the
// Tab.
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
#Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
// Create a tab with text corresponding to the page title defined by the adapter.
// Also specify this Activity object, which implements the TabListener interface, as the
// listener for when this tab is selected.
actionBar.addTab(
actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}
main();
}
/* WEITER UNTEN SIND DIE TABSELECTED FUNKTIONEN !!!!
//#Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
// #Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
// When the given tab is selected, switch to the corresponding page in the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
}
// #Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
private FragmentTransaction mCurTransaction = null;
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
#Override
public int getItemPosition(Object object) {
return POSITION_NONE; //To make notifyDataSetChanged() do something
}
#Override
public Fragment getItem(int i) {
// Fragment building_fragment = new BuildingFragment();
Fragment room_fragment = new RoomFragment();
Fragment transl_fragment = new TransliterationFragment();
// Fragment device_fragment = new DeviceFragment();
Bundle args = new Bundle();
switch(i){
case 0:
room_fragment.setArguments(args);
return room_fragment;
case 1:
return transl_fragment;
case 2:
// args.putInt(RoomFragment.ARG_SECTION_NUMBER, i);
// room_fragment.setArguments(args);
return room_fragment;
default: return null;
}
}
#Override
public int getCount() {
return 2;
}
#Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0: return "a";
case 1: return "b";
case 2: return "c";
}
return null;
}
#Override
public Object instantiateItem(View container, int position) {
if (mCurTransaction == null) {
mCurTransaction = getSupportFragmentManager().beginTransaction();
}
// TODO Auto-generated method stub
Fragment fragment = getItem(position);
if (fragment!=null){
System.out.println("Fragment Found!");
mCurTransaction.attach(fragment);
}
return fragment;//super.instantiateItem(container, position);
}
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.menu_play:
play();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
#Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem switchButton = menu.findItem(R.id.menu_play);
}
public class Tweet {
String content;
String sure;
String vers;
}
public class Tweet2 {
String content;
String sure;
String vers;
}
public void onTabReselected(Tab tab, android.app.FragmentTransaction ft) {
// TODO Auto-generated method stub
}
public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) {
// TODO Auto-generated method stub
mViewPager.setCurrentItem(tab.getPosition());
}
public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) {
// TODO Auto-generated method stub
}
//HERE IS THE CODE FOR SELECTING THE SECOND ITEM
public void one_changed()
{
TransliterationFragment fragment_meaning = (TransliterationFragment) getSupportFragmentManager().findFragmentById(R.id.myfragment2);
Toast.makeText(getApplicationContext(),"Change Selection", Toast.LENGTH_SHORT).show();
fragment_meaning.change_selected(); // do what updates are required
}
AND THIS IS THE RELEVANT CODE OF THE SECOND FRAGMENT, I can see the string "Hallo" is in the console, so the function is really called, but i the Item isnt selected.
public void change_selected()
{
System.out.println("Hallo");
ListView list=getListView();
list.setSelection(4);
}
Its working now when i add this code in the function on_changed in the parent activity:
TransliterationFragment fragment_meaning = (TransliterationFragment) getSupportFragmentManager().findFragmentByTag("android:switcher:"+R.id.pager+":1");
fragment_meaning.change_selected(); // do what updates are required

Disable SlidingMenu in activity

I have one parent class which uses SlidingMenu. And the childs extending parent class shows the sliding menu on Home Icon click.
How to disable the sliding menu in the child classes?
codes Parent Class :
public class BCFragmentActivity extends SlidingFragmentActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setSlidingActionBarEnabled(true);
setBehindContentView(R.layout.slide_menu);
getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
getSlidingMenu().setShadowDrawable(R.drawable.shadow);
getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
getSlidingMenu().setBehindScrollScale(0.25f);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
toggle();
return true;
}
return super.onOptionsItemSelected(item);
}
}
codes for child Class :
public class SettingsPagerActivity extends BCFragmentActivity {
private ActionBar actionBar;
private ViewPager settingsPager;
private Tab profilesTab;
private Tab accountsTab;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings_pager);
actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
settingsPager = (ViewPager) findViewById(R.id.settingsPage);
settingsPager.setOnPageChangeListener(pageChangeListener);
FragmentManager fm = getSupportFragmentManager();
profilesTab = actionBar.newTab()
.setText("Profile")
.setTabListener(tabListener);
accountsTab = actionBar.newTab()
.setText("Account")
.setTabListener(tabListener);
actionBar.addTab(profilesTab);
actionBar.addTab(accountsTab);
}
ActionBar.TabListener tabListener = new ActionBar.TabListener() {
#Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
settingsPager.setCurrentItem(tab.getPosition());
}
#Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
#Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
};
ViewPager.SimpleOnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
#Override
public void onPageSelected(int position) {
super.onPageSelected(position);
actionBar.setSelectedNavigationItem(position);
}
};
}
I can't think of a way to "disable" it, but you can remove all of the functionality by calling in the child class
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
This will disable any gesture detection for your sliding menu. If you have an action bar, do the usual in onCreate:
actionBar.setDisplayHomeAsUpEnabled(true);
and handle it as if you don't have a SlidingMenu:
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Try overriding onBackPressed() in your child activity.
#Override
public void onBackPressed() {
this.finish();
overridePendingTransition(0, 0);
}

Categories

Resources