博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Actionbarsherlock Demo 浅析 :Custom Navigation
阅读量:4623 次
发布时间:2019-06-09

本文共 1422 字,大约阅读时间需要 4 分钟。

-------------Custom Navigation(自定义导航栏)-----------------

- - - -custom_view.xml:

- - - - Activity中的内容:

protected void onCreate(Bundle savedInstanceState) {        setTheme(SampleList.THEME); //Used for theme switching in samples        super.onCreate(savedInstanceState);        setContentView(R.layout.text);        ((TextView)findViewById(R.id.text)).setText(R.string.custom_navigation_content);        //Inflate the custom view        View customNav = LayoutInflater.from(this).inflate(R.layout.custom_view, null);        //Bind to its state change        ((RadioGroup)customNav.findViewById(R.id.radio_nav)).setOnCheckedChangeListener(new OnCheckedChangeListener() {            @Override            public void onCheckedChanged(RadioGroup group, int checkedId) {                Toast.makeText(CustomNavigation.this, "Navigation selection changed.", Toast.LENGTH_SHORT).show();            }        });        //Attach to the action bar        getSupportActionBar().setCustomView(customNav);        getSupportActionBar().setDisplayShowCustomEnabled(true);    }

- - - -关键:getSupportActionBar().setCustomView(customNav);

- - - -getSupportActionBar()方法能够获得当前Actionbar的实例,ActionBar中的setCustomView(View view)方法,将动作栏设置为自定义导航模式,并提供自定义导航视图View。自定义导航视图可以出现在应用程序图标和任何动作按钮之间,可以使用任何可用的空间。该自定义导航视图一般用于浏览器或者其他类似于搜索的导航机制。

转载于:https://www.cnblogs.com/dingchao823/p/4794304.html

你可能感兴趣的文章
使用XV-11激光雷达做hector_slam
查看>>
布局技巧4:使用ViewStub
查看>>
学习记事
查看>>
java 子类重写父类的方法应注意的问题
查看>>
[LevelDB] LevelDB理论基础
查看>>
【codecombat】 试玩全攻略 第一关kithguard地牢
查看>>
【DP】 POJ 1191 棋盘分割 记忆化搜索
查看>>
自动化测试 Appium之Python运行环境搭建 Part2
查看>>
说说DBA职责和目标
查看>>
从头认识Spring-2.4 基于java的标准注解装配-@Inject-限定器@Named
查看>>
sql server 实现多表连接查询
查看>>
Python标准库:内置函数getattr(object, name[, default])
查看>>
转:android 自定义RadioButton样式
查看>>
HTTP请求过程
查看>>
织梦多域名解析到同一个空间导致打开链接不一致怎么办?
查看>>
Xcode10 library not found for -lstdc++ 找不到问题
查看>>
Mysql 8.0.13如何重置密码
查看>>
发布功能完成
查看>>
excel 合并单元格
查看>>
iOS设计模式简介
查看>>