Android的ActionBarSherlock自定义视图 [英] Android ActionBarSherlock Custom View

查看:153
本文介绍了Android的ActionBarSherlock自定义视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了一个自定义的顶栏我ActionBarSherlock在

I have added a custom top bar to my ActionBarSherlock as in

getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setCustomView(R.layout.my_custom_view);

现在这个包含R.id.back的资源ID图像按钮。如何处理这个项目的onclick监听器。

Now this contains an Image Button with the resource id of R.id.back. How do i handle the onclick listener of this item.

亲切的问候,

推荐答案

您也可以抬高你的看法,如果你得到一个布局吹气和搜索按钮,然后附加一个点击监听器。

You can also inflate your view if you get a layout inflater and search for the button and then attach a click listener.

因此​​,例如东西沿着这些线路,如果你有按键标识则myButton:

So for example something along these lines if your button had id "myButton":

getSupportActionBar().setDisplayShowCustomEnabled(true);
View view = getLayoutInflater().inflate(R.layout.my_custom_view, null);
Button mybutton = (Button)view.findViewById(R.id.myButton);            
mybutton.setOnClickListener(new OnClickListener()
{
        @Override
        public void onClick(View v)
        {
        /** Your click actions here. */
        }
});
getSupportActionBar().setCustomView(view);

这篇关于Android的ActionBarSherlock自定义视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆