@Test public void setAction_setsButtonClickListener() { MaterialBanner.OnActionListener listener = mock(MaterialBanner.OnActionListener.class); banner.setAction(listener); Button button = banner.findViewById(R.id.button); button.performClick(); verify(listener).onAction(); }
public void setAction(OnActionListener listener) { Button button = findViewById(R.id.button); button.setOnClickListener(v -> listener.onAction()); }
MaterialBanner extends FrameLayout { public void setAction(OnActionListener listener) { Button button = findViewById(R.id.button); button.setOnClickListener(v -> listener.onAction()); } }
MaterialBanner extends FrameLayout { public void setAction(OnActionListener listener) { Button button = findViewById(R.id.button); button.setOnClickListener(v -> listener.onAction()); } MaterialBanner(@NonNull Context context);  MaterialBanner(@NonNull Context context, @Nullable AttributeSet attrs);  MaterialBanner(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr); }
MaterialBanner extends FrameLayout { public void setAction(OnActionListener listener) { Button button = findViewById(R.id.button); button.setOnClickListener(v -> listener.onAction()); } MaterialBanner(@NonNull Context context);  MaterialBanner(@NonNull Context context, @Nullable AttributeSet attrs);  MaterialBanner(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr); void setText(String text); void setText(CharSequence text); void setActionText(String actionTitle); void setAction(OnActionListener listener); }
MaterialBanner extends FrameLayout { public void setAction(OnActionListener listener) { Button button = findViewById(R.id.button); button.setOnClickListener(v -> listener.onAction()); } MaterialBanner(@NonNull Context context);  MaterialBanner(@NonNull Context context, @Nullable AttributeSet attrs);  MaterialBanner(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr); void setText(String text); void setText(CharSequence text); void setActionText(String actionTitle); void setAction(OnActionListener listener);  }