Ich habe es letztendlich gemäß den Designrichtlinien selbst geschrieben:
ActionFragment.java
public class ActionFragment extends Fragment implements View.OnClickListener {
private static Listener mListener;
private CircledImageView vIcon;
private TextView vLabel;
public static ActionFragment create(int iconResId, int labelResId, Listener listener) {
mListener = listener;
ActionFragment fragment = new ActionFragment();
Bundle args = new Bundle();
args.putInt("ICON", iconResId);
args.putInt("LABEL", labelResId);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_action, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
vIcon = (CircledImageView) view.findViewById(R.id.icon);
vLabel = (TextView) view.findViewById(R.id.label);
vIcon.setImageResource(getArguments().getInt("ICON"));
vLabel.setText(getArguments().getInt("LABEL"));
view.setOnClickListener(this);
}
@Override
public void onClick(View v) {
mListener.onActionPerformed();
}
public interface Listener {
public void onActionPerformed();
}
}
layout/fragment_action.xml
color/action_button.xml
Beispiel Verwendung (z.B. in FragmentGridPagerAdapter)
ActionFragment.create(R.drawable.ic_full_open_on_phone, R.string.open_on_phone, new ActionFragment.Listener() {
@Override
public void onActionPerformed() {
}
});