/** {@inheritDoc} */ @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) Log.v(TAG, "onCreateView"); resolveTheme(); inflater = getThemeInflater(inflater); View v = inflater.inflate(R.layout.lb_guidedstep_fragment, container, false); ViewGroup guidanceContainer = (ViewGroup) v.findViewById(R.id.content_fragment); ViewGroup actionContainer = (ViewGroup) v.findViewById(R.id.action_fragment); Guidance guidance = onCreateGuidance(savedInstanceState); View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance); guidanceContainer.addView(guidanceView); View actionsView = mActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(actionsView); GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() { @Override public void onGuidedActionEdited(GuidedAction action, boolean entering) { runImeAnimations(entering); if (!entering) { GuidedStepSupportFragment.this.onGuidedActionEdited(action); } } }; mAdapter = new GuidedActionAdapter(mActions, this, this, editListener, mActionsStylist); mListView = mActionsStylist.getActionsGridView(); mListView.setAdapter(mAdapter); int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction(); mListView.setSelectedPosition(pos); return v; }
private void setActionView(View action) { mAdapter = new DialogActionAdapter( new Action.Listener() { @Override public void onActionClicked(Action action) { // eat events if action is disabled or only displays info if (!action.isEnabled() || action.infoOnly()) { return; } /** * If the custom lister has been set using {@link * #setListener(DialogActionAdapter.Listener)}, use it. If not, use the activity's * default listener. */ if (mListener != null) { mListener.onActionClicked(action); } else if (getActivity() instanceof Action.Listener) { Action.Listener listener = (Action.Listener) getActivity(); listener.onActionClicked(action); } } }, new Action.OnFocusListener() { @Override public void onActionFocused(Action action) { if (getActivity() instanceof Action.OnFocusListener) { Action.OnFocusListener listener = (Action.OnFocusListener) getActivity(); listener.onActionFocused(action); } } }, mActions); if (action instanceof VerticalGridView) { mListView = (VerticalGridView) action; } else { mListView = (VerticalGridView) action.findViewById(R.id.list); if (mListView == null) { throw new IllegalStateException("No ListView exists."); } // mListView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE); // mListView.setWindowAlignmentOffsetPercent(0.5f); // mListView.setItemAlignmentOffset(0); // // mListView.setItemAlignmentOffsetPercent(VerticalGridView.ITEM_ALIGN_OFFSET_PERCENT_DISABLED); mListView.setWindowAlignmentOffset(0); mListView.setWindowAlignmentOffsetPercent(50f); mListView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE); View selectorView = action.findViewById(R.id.selector); if (selectorView != null) { mSelectorAnimator = new SelectorAnimator(selectorView, mListView); mListView.setOnScrollListener(mSelectorAnimator); } } mListView.requestFocusFromTouch(); mListView.setAdapter(mAdapter); mListView.setSelectedPosition( (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction()); action.setTag(R.id.list, mListView); action.setTag(R.id.selector, action.findViewById(R.id.selector)); }
public void setSelectedPosition(int position) { mListView.setSelectedPosition(position); }