public Holder onCreateViewHolder()

in WearAccessibilityApp/Wearable/src/main/java/com/example/android/wearable/wear/wearaccessibilityapp/LongListRecyclerViewAdapter.java [58:113]


    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
        final View view;
        switch (viewType) {
            case SampleAppConstants.TITLE:
                // Programmatically set the text of the title here.
                view = mInflater.inflate(R.layout.title_layout, parent, false);
                TextView titleView = view.findViewById(R.id.title_text);
                titleView.setText(R.string.a_long_list);
                break;
            case SampleAppConstants.SWITCH:
                // Reference the switch widget's text and view.
                view = mInflater.inflate(R.layout.long_list_switch_widget_layout, parent, false);
                TextView switchText = view.findViewById(R.id.switch_text);
                switchText.setText(R.string.bottom_action_drawer);

                mSwitchWidget = view.findViewById(R.id.switch_widget);

                view.setContentDescription(
                        mContext.getResources()
                                .getString(
                                        R.string.switch_bottom_action_drawer,
                                        getSwitchToggleString(mSwitchWidget.isChecked())));

                // Set the OnClickListener (Observer pattern used here).
                view.setOnClickListener(
                        new OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                mSwitchWidget.setChecked(!(mSwitchWidget.isChecked()));
                                if (mSwitchChangeListener != null) {
                                    mSwitchChangeListener.onChange(mSwitchWidget.isChecked());
                                }
                                view.setContentDescription(
                                        mContext.getResources()
                                                .getString(
                                                        R.string.switch_bottom_action_drawer,
                                                        getSwitchToggleString(
                                                                mSwitchWidget.isChecked())));
                            }
                        });
                break;
            case SampleAppConstants.HEADER_FOOTER:
                view = mInflater.inflate(R.layout.header_footer_layout, parent, false);
                break;
            case SampleAppConstants.PROGRESS_BAR:
                view = mInflater.inflate(R.layout.progress_bar_layout, parent, false);
                break;
            case SampleAppConstants.NORMAL:
                view = mInflater.inflate(R.layout.shifted_app_item_layout, parent, false);
                break;
            default:
                view = mInflater.inflate(R.layout.shifted_app_item_layout, parent, false);
                break;
        }
        return new Holder(view);
    }