android实现底部菜单栏
2010-07-13 21:28:00 来源:WEB开发网android程序,许多时候需要菜单栏显示在底部或顶部,但是没有很好的组建供程序员调用,过自定义了一个视图,用来实现底部菜单栏,效果如下图:
实现的主要代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
linearLayout = (LinearLayout) findViewById(R.id.home);
linearLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
linearLayout
.setBackgroundResource(R.drawable.tab_two_highlight);
publish.setBackgroundResource(R.drawable.tab_one_normal);
change.setBackgroundResource(R.drawable.tab_one_normal);
more.setBackgroundResource(R.drawable.tab_one_normal);
}
});
linearLayout
.setBackgroundResource(R.drawable.tab_two_highlight);
publish = (LinearLayout) findViewById(R.id.publish);
publish.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
publish.setBackgroundResource(R.drawable.tab_two_highlight);
linearLayout.setBackgroundResource(R.drawable.tab_one_normal);
change.setBackgroundResource(R.drawable.tab_one_normal);
more.setBackgroundResource(R.drawable.tab_one_normal);
}
});
change = (LinearLayout) findViewById(R.id.change);
change.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
change.setBackgroundResource(R.drawable.tab_two_highlight);
linearLayout.setBackgroundResource(R.drawable.tab_one_normal);
更多精彩
赞助商链接