开发者

button bar similar to twitter app for android

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:

button bar similar to twitter app for android

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开发者_如何学Python 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜