Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit:</strong> I currently recommend using <a href="http://www.actionbarsherlock.com" rel="nofollow">ActionBarSherlock</a> instead of android-actionbar. It allows use of the native Android action bar on newer devices and provides full API compatibility on older ones.</p> <hr> <p><em>Original answer:</em></p> <p>I would recommend the mimic-native-api branch, it is more up to date and has some very useful features such as being able to define actions from XML. (I'm using it in a large project and it's working splendidly.)</p> <p>However, you should be able to do this in the master branch by creating your own implementation of AbstractAction -- e.g. add another class similar to IntentAction called "ResultAction" and have it use mContext.startActivityForResult(mIntent) instead of mContext.startActivity(mIntent). You'll also need to store the requestCode that you want to watch for in your onActivityResult.</p> <p>Some <em>completely untested</em> example code:</p> <pre class="lang-java prettyprint-override"><code>public static class ResultAction extends ActionBar.AbstractAction { private Context mContext; private Intent mIntent; private int mRequestCode; // note: you could use this to start activities normally (with no result) // by using a negative value for requestCode. public ResultAction(Context context, Intent intent, int drawable, int requestCode) { super(drawable); mContext = context; mIntent = intent; mRequestCode = requestCode; } @Override public void performAction(View view) { try { mContext.startActivityForResult(mIntent, mRequestCode); } catch (ActivityNotFoundException e) { Toast.makeText(mContext, mContext.getText(R.string.actionbar_activity_not_found), Toast.LENGTH_SHORT).show(); } } } </code></pre> <p>You'll need to override onActivityResult in your activity to get the result code, as documented <a href="http://developer.android.com/reference/android/app/Activity.html#StartingActivities" rel="nofollow" title="Starting Activities and Getting Results">here</a>.</p>
    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.
    3. 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