I have added a custom top bar to my ActionBarSherlock as in
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setCustomView(R.layout.my_custom_view);
Now this contains an Image Button with the resource id of R.id.back. How do i handle the onclick listener of this item.
Kind Regards,
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);
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With