【问题标题】:Custom SherlockActionBar layout above TabsTabs 上方的自定义 SherlockActionBar 布局
【发布时间】:2012-09-06 19:47:55
【问题描述】:

我是 SherlockActionBar 开发的新手,我想要的是“Foursquare-like”顶部操作栏,下面有标签,请参阅:

正如 Richard Lewin 在 Android ActionBarSherlock Top Bar 中所描述的那样,我可以轻松地添加菜单操作,例如“搜索”或“签到”,它们会出现在顶部栏的右侧,但是如果我需要添加自定义“向上”,我应该怎么做按钮(而不是徽标)和自定义(例如粗体)标题?我可以只使用 SherlockActionBar XML-styles 还是我需要实现新组件?

【问题讨论】:

    标签: android android-actionbar


    【解决方案1】:

    Alexander,您需要为您的操作栏创建自定义布局,请参见此处的示例 Show dropdown programatically in ActionBar / ActionBarSherlock

    在此示例中,描述了带有微调器和两个操作的操作栏。

    【讨论】:

      【解决方案2】:

      在您的活动中,启用向上按钮(通常在 onCreate() 中):

      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
      

      然后实现它的行为:

      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
          case android.R.id.home:
      
              // do something
      
              return true;
          }
          return false;
      }
      

      对于操作栏主题:http://actionbarsherlock.com/theming.html

      对于标签,我认为您可以像在 android 4 实现中一样:http://developer.android.com/guide/topics/ui/actionbar.html#Tabs

      玩得开心:)

      【讨论】:

      • 您需要更多信息/帮助吗?
      • 非常感谢!简洁明了
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-07
      相关资源
      最近更新 更多