Code example for ActionProvider

    static final int LIST_LENGTH = 3;
    Context mContext;
    public MainOverFlowProvider(Context context) {
        mContext = context;
    public View onCreateActionView() {
        return null; 
    public View onCreateActionView(MenuItem forItem) {
        // Inflate the action view to be shown on the action bar. 
        LayoutInflater layoutInflater = LayoutInflater.from(mContext);
        View view = layoutInflater.inflate(R.layout.action_provider, null);
        ImageButton button = (ImageButton) view.findViewById(;
        button.setOnClickListener(new View.OnClickListener() {
Contextual code suggestions in your IDE  Get Codota for Java