类似Android的Twitter的应用程序按钮栏 [英] button bar similar to twitter app for android

查看:189
本文介绍了类似Android的Twitter的应用程序按钮栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得与Twitter的应用程序的按钮栏类似的标签效果。

我想点击一个按钮,并更改视图下来。我可以切换活动,但我认为这是错误的,或者不是?

顶栏必须解决像一帧。像这样的:

好吧,现在我后我的想法的一部分(我发现这里类似的东西:<一href=\"http://www.talkandroid.com/android-forums/android-development-answers-tutorials-$c$c-snippets/1515-how-i-open-image-imagebutton.html\" rel=\"nofollow\">http://www.talkandroid.com/android-forums/android-development-answers-tutorials-$c$c-snippets/1515-how-i-open-image-imagebutton.html)

code:

  newsButton =(的ImageButton)findViewById(R.id.news);
        newsButton.setOnClickListener(新View.OnClickListener(){        @覆盖
        公共无效的onClick(查看视图){            //在点击进入新闻观(还没有任何活动)
            的setContentView(R.layout.news);        }    });


解决方案

就像在的谷歌IO应用

如果这样,源$ C ​​$ c是免费提供的这里


好吧,在谷歌是如何做的一个小游:


  1. activity_home.xml -layout
    包括( 21号线)
    actionbar.xml -layout(这样做
    在每一个布局,使该动作条
    不能老是重复)。

  2. actionbar.xml -layout
    创建一个 的LinearLayout
    用户界面元素。

  3. 然后,例如在
    <一href=\"http://$c$c.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/ui/HomeActivity.java#58\"相对=nofollow> HomeActivity -activity套
    内容视图到
    activity_home.xml -layout,接收
    一个ActivityHelper类和调用
    setupActionBar() -method。

  4. 的mantioned ActivityHelper
    HG /安卓/ src目录/ COM /
    谷歌/安卓/应用/ iosched /
    UTIL /
    -package和有
    <一href=\"http://$c$c.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/util/ActivityHelper.java#135\"相对=nofollow> setupActionBar() - 方法这
    创建行动吧。

这可能更容易那么它看起来。阅读您的方式通过源$ C ​​$ c和自己尝试一下。

I want to obtain a similar tab effect with the button bar of twitter app.

I wish to click on a button and change the view down. I can switch activity but I think It's wrong, or not?

The top bar have to be fix like a frame. Like this:

Ok now I post a part of my idea (i found something similar here: http://www.talkandroid.com/android-forums/android-development-answers-tutorials-code-snippets/1515-how-i-open-image-imagebutton.html)

code:

        newsButton = (ImageButton) findViewById(R.id.news);
        newsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {

            // on click go to the news view (no activity yet)
            setContentView(R.layout.news);

        }

    });

解决方案

Like in the Google IO App?

If so, the Source Code is freely available here.


Okay, a little tour on how Google does it:

  1. The activity_home.xml-layout includes (Line 21) the actionbar.xml-layout (This is done in every Layout so the Actionbar must not always be duplicated).
  2. The actionbar.xml-Layout creates a LinearLayout for the UI-Elements.
  3. Then, for example the HomeActivity-Activity sets the content view to the activity_home.xml-layout, receives an ActivityHelper-class and calls its setupActionBar()-method.
  4. The mantioned ActivityHelper-class is in the hg/ android/ src/ com/ google/ android/ apps/ iosched/ util/-package and has the setupActionBar()-method which creates the Action bar.

This might be easier then it looks. Read your way through the Source Code and try it yourself.

这篇关于类似Android的Twitter的应用程序按钮栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆