Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing both SlidingActivityBase and SherlockFragmentActivity to create a Sliding Menu
    primarykey
    data
    text
    <p>I've been following this tutorial to create a sliding menu:</p> <p><a href="http://www.youtube.com/watch?v=LWTYQ2g597o" rel="nofollow">http://www.youtube.com/watch?v=LWTYQ2g597o</a></p> <p>And because Im using Sherlock, I had to change my class declaration from this:</p> <pre><code>public class BaseActivity extends SlidingFragmentActivity </code></pre> <p>to the following:</p> <pre><code>public class RggarbActionBar extends SherlockFragmentActivity implements SlidingActivityBase </code></pre> <p>and now Im getting a NullPointerException whenever I use the getSlidingMenu() method which stays empty down there in my class and returns null.</p> <p>Here is my whole class:</p> <pre><code>public class RggarbActionBar extends SherlockFragmentActivity implements SlidingActivityBase { protected ListFragment listFragment; @Override public boolean onCreateOptionsMenu(Menu menu) { listFragment = new RggarbSlidingMenu(); SlidingMenu slidingMenu = getSlidingMenu(); slidingMenu.setShadowWidth(15);//outsource these slidingMenu.setBehindOffset(60); slidingMenu.setFadeDegree(0.35f); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); MenuInflater inflater = getSupportMenuInflater(); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); ActionBar actionBar = getSherlock().getActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#680e96"))); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayUseLogoEnabled(false); actionBar.setHomeButtonEnabled(true); actionBar.setIcon(R.drawable.logo_icon); inflater.inflate(R.menu.action_bar_items, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if(itemId == android.R.id.home) { toggle(); return true; } else if (itemId == R.id.abFeed) { Intent feed = new Intent(this, Home.class); startActivity(feed); return true; } else if (itemId == R.id.abNotifications) { Intent notifications = new Intent(this, Notifications.class); startActivity(notifications); return true; } else if (itemId == R.id.abAddNewItem) { Intent addNewItem = new Intent(this, ItemAdd.class); startActivity(addNewItem); return true; } else if (itemId == R.id.abSearch) { Intent search = new Intent(this, SearchItems.class); startActivity(search); return true; } else { return onOptionsItemSelected(item); //watch out for this one. if any problems occur change to "return true" } } public class BasePagerAdapter extends FragmentPagerAdapter{ private List&lt;Fragment&gt; mFragments = new ArrayList&lt;Fragment&gt;(); private ViewPager mPager; public BasePagerAdapter(FragmentManager fm, ViewPager vp){ super(fm); mPager = vp; mPager.setAdapter(this); for (int i = 0; i &lt; 3; i++){ addTab(new RggarbSlidingMenu()); } } public void addTab(Fragment frag){ mFragments.add(frag); } @Override public Fragment getItem(int position){ return mFragments.get(position); } @Override public int getCount(){ return mFragments.size(); } } @Override public void setBehindContentView(View view, LayoutParams layoutParams) { // TODO Auto-generated method stub } @Override public void setBehindContentView(View view) { // TODO Auto-generated method stub } @Override public void setBehindContentView(int layoutResID) { // TODO Auto-generated method stub } @Override public SlidingMenu getSlidingMenu() { // TODO Auto-generated method stub return null; } @Override public void toggle() { // TODO Auto-generated method stub } @Override public void showContent() { // TODO Auto-generated method stub } @Override public void showMenu() { // TODO Auto-generated method stub } @Override public void showSecondaryMenu() { // TODO Auto-generated method stub } @Override public void setSlidingActionBarEnabled(boolean slidingActionBarEnabled) { // TODO Auto-generated method stub } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload