You can also inflate your performance if you get an inflatable layout and search for a button and then attach a click listener.
So, for example, something like these lines if your button had the identifier "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) { } }); getSupportActionBar().setCustomView(view);
source share