类似Android的Twitter的应用程序按钮栏应用程序、按钮、类似、Twitter

2023-09-06 18:51:24 作者:优雅议员

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

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

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

好吧,现在我后我的想法的一部分(我发现这里类似的东西: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是免费提供的这里。

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

activity_home.xml -layout包括( 21号线) actionbar.xml -layout(这样做在每一个布局,使该动作条不能老是重复)。的 actionbar.xml -layout创建一个 的LinearLayout 的用户界面元素。然后,例如在 HomeActivity -activity套内容视图到 activity_home.xml -layout,接收一个ActivityHelper类和调用其 setupActionBar() -method。的mantioned ActivityHelper 级在 HG /安卓/ src目录/ COM /谷歌/安卓/应用/ iosched /UTIL / -package和有 setupActionBar() - 方法这创建行动吧。怎么创建第一个Android工程,并运行应用程序

这可能更容易那么它看起来。阅读您的方式通过源$ 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:

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). The actionbar.xml-Layout creates a LinearLayout for the UI-Elements. 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. 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.