类似Android的Twitter的应用程序按钮栏 [英] button bar similar to twitter app for android
问题描述
我想获得与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是免费提供的这里。
好吧,在谷歌是如何做的一个小游:
- 的
activity_home.xml
-layout
包括( 21号线)actionbar.xml
-layout(这样做
在每一个布局,使该动作条
不能老是重复)。 - 的
actionbar.xml
-layout
创建一个的LinearLayout
的
用户界面元素。 - 然后,例如在
<一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。 - 的mantioned
ActivityHelper
级
在HG /安卓/ src目录/ COM /
-package和有
谷歌/安卓/应用/ iosched /
UTIL /
<一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:
- The
activity_home.xml
-layout includes (Line 21) theactionbar.xml
-layout (This is done in every Layout so the Actionbar must not always be duplicated). - The
actionbar.xml
-Layout creates aLinearLayout
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 itssetupActionBar()
-method. - The mantioned
ActivityHelper
-class is in thehg/ 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屋!