Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So basically in order to complete this, I can't use showPopup because that's only on API 11 and up. </p> <p>I had so much trouble trying to get it all to work properly on the older versions of Android due, at least partially, to some incongruities with ActionBarSherlock that I didn't fully understand. Which imports I used were very important to getting the app to launch without crashes, here they are: </p> <p>import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem;</p> <p>Beyond that, I found another Stack Overflow post that highlighted the method openOptionsMenu. So in my fragment, I add an onClickListener for my menuButton ImageView. When the user taps that, the main activity is told to openOptionsMenu, which runs onCreateOptionsMenu. Right now the onMenuItemClick method doesn't seem to be doing its job, but I think I'll be able to sort that out fairly quickly tomorrow. There is one difference to how the menu used to load now though. Rather than popping up right on top of the ImageView, it loads on the bottom of the screen (in either the old way, or the new vertical menu in ICS). So there's that, but it's not a big problem. </p> <p>I think that just about covers it.</p> <p>Code: </p> <pre><code> ImageView menuImg = (ImageView) activity.findViewById(R.id.menuImageView); menuImg.setOnClickListener(new OnClickListener() { public void onClick(View v) { activity.openOptionsMenu(); } }); </code></pre> <hr> <pre><code>public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.main_menu, menu); return true; } </code></pre> <hr> <pre><code>public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.demographics: return true; case R.id.settings: Log.v("v", "settings clicked"); return true; default: return false; } } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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