1

I came across this thread on how to split icons across the top and bottom action bars: How to add actions to the top part of a split ActionBar. My question is where do the methods mentioned in the first answer go (setDisplayOptions & setCustomView)?

Thanks!

Community
  • 1
  • 1
locoMotion
  • 372
  • 1
  • 3
  • 15

1 Answers1

2

The two methods for which you are asking should go in

onCreate(Bundle savedInstanceState) 

method. Read more about onCreate method here .

  • I have another question for you if you're interested in answering- `onCreate` method is this: `protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); getActionBar().setCustomView(R.layout.custom_action_bar_top); }` I created `custom_action_bar_top.xml` and added my icon item to it but I'm getting an error when I compile. Feeling a bit sheepish for asking. I know this is really basic but I'm lost. – locoMotion Feb 15 '14 at 06:09
  • The two lines you have at bottom should be above `setContentView(R.layout.activity_main);` –  Feb 15 '14 at 06:12
  • Hi. I've moved the custom function calls above the `setContentView` call and below the `super.create` call. The error is caused by: "(...)Landroid/view/item;" not found – locoMotion Feb 15 '14 at 06:22
  • Have you added the jar or the library needed for that views? –  Feb 15 '14 at 06:24
  • Hmm. All I have added for the top action bar icons are: 1) the two method calls in my main activity; 2)cusom_action_bar_top.xml to the layout folder- this file has my item element in it – locoMotion Feb 15 '14 at 06:27
  • Sorry, the imports in the main activity are `import android.os.Bundle; import android.app.ActionBar; import android.app.Activity; import android.view.Menu;` – locoMotion Feb 15 '14 at 06:29
  • Please have a look here http://www.vogella.com/tutorials/AndroidActionBar/article.html section **Enabling the split action bar** –  Feb 15 '14 at 06:32
  • Not sure mate. I read the entire article but didn't find any answers. Lots of good resources there though :) – locoMotion Feb 15 '14 at 07:11