in DrawableTinting/Application/src/main/java/com/example/android/drawabletinting/DrawableTintingFragment.java [166:213]
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.tinting_fragment, container, false);
// Set a drawable as the image to display
mImage = v.findViewById(R.id.image);
mImage.setImageResource(R.drawable.btn_default_normal_holo);
// Get text labels and SeekBars for the four color components: ARGB
mAlphaBar = v.findViewById(R.id.alphaSeek);
mAlphaText = v.findViewById(R.id.alphaText);
mGreenBar = v.findViewById(R.id.greenSeek);
mGreenText = v.findViewById(R.id.greenText);
mRedBar = v.findViewById(R.id.redSeek);
mRedText = v.findViewById(R.id.redText);
mBlueText = v.findViewById(R.id.blueText);
mBlueBar = v.findViewById(R.id.blueSeek);
// Set a listener to update tinted image when selections have changed
mAlphaBar.setOnSeekBarChangeListener(mSeekBarListener);
mRedBar.setOnSeekBarChangeListener(mSeekBarListener);
mGreenBar.setOnSeekBarChangeListener(mSeekBarListener);
mBlueBar.setOnSeekBarChangeListener(mSeekBarListener);
// Set up the spinner for blend mode selection from a string array resource
mBlendSpinner = v.findViewById(R.id.blendSpinner);
SpinnerAdapter sa = ArrayAdapter.createFromResource(v.getContext(),
R.array.blend_modes, android.R.layout.simple_spinner_dropdown_item);
mBlendSpinner.setAdapter(sa);
// Set a listener to update the tinted image when a blend mode is selected
mBlendSpinner.setOnItemSelectedListener(mBlendListener);
// Select the first item
mBlendSpinner.setSelection(0);
mMode = MODES[0];
if (savedInstanceState != null) {
// Restore the previous state if this fragment has been restored
mBlendSpinner.setSelection(savedInstanceState.getInt(STATE_BLEND));
mAlphaBar.setProgress(savedInstanceState.getInt(STATE_ALPHA));
mRedBar.setProgress(savedInstanceState.getInt(STATE_RED));
mGreenBar.setProgress(savedInstanceState.getInt(STATE_GREEN));
mBlueBar.setProgress(savedInstanceState.getInt(STATE_BLUE));
}
// Apply the default blend mode and color
updateTint(getColor(), getTintMode());
return v;
}