Skip to content Skip to sidebar Skip to footer

Android Actionbarsherlock Custom View

I have added a custom top bar to my ActionBarSherlock as in getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(R.layout.my_custom_view);

Solution 1:

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

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

getSupportActionBar().setDisplayShowCustomEnabled(true);
Viewview= getLayoutInflater().inflate(R.layout.my_custom_view, null);
Buttonmybutton= (Button)view.findViewById(R.id.myButton);            
mybutton.setOnClickListener(newOnClickListener()
{
        @OverridepublicvoidonClick(View v)
        {
        /** Your click actions here. */
        }
});
getSupportActionBar().setCustomView(view);

Post a Comment for "Android Actionbarsherlock Custom View"