button bar similar to twitter app for android

六眼飞鱼酱① 提交于 2019-12-08 04:05:11

问题


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);

        }

    });

回答1:


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.




回答2:


I think these controls are Radio Button/ Radio Group with customization.



来源:https://stackoverflow.com/questions/6533434/button-bar-similar-to-twitter-app-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!