Example usage for android.widget ViewSwitcher findViewById

List of usage examples for android.widget ViewSwitcher findViewById

Introduction

In this page you can find the example usage for android.widget ViewSwitcher findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:com.pressurelabs.flowopensource.TheHubActivity.java

/**
 * Hides the Options Menu and uses a ViewSwitcher to quick turn the exisiting TextView with the
 * Flow's name into an EditText for the user to rename.
 *
 * @param cardPosition position of cardview in adapter
 * @param cardViewClicked the cardview view object clicked
 */// ww  w . j  a va  2 s  .  c  o m
private void renameFlow(final int cardPosition, final View cardViewClicked) {
    menuState = AppConstants.MENU_ITEMS_HIDE;
    invalidateOptionsMenu();
    final ViewSwitcher switcher = (ViewSwitcher) cardViewClicked.findViewById(R.id.hub_rename_switcher);
    final EditText rename = (EditText) switcher.findViewById(R.id.hub_item_flow_rename);

    AppUtils.setNameInputFilters(rename);

    rename.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (rename.hasFocus()) {
                showEditPopupWindow(rename, cardViewClicked, switcher, cardPosition);
            }
        }
    });

    switcher.showNext();

    rename.requestFocus();
    /* Forces keyboard */

}

From source file:mn.today.TheHubActivity.java

/**
 * Hides the Options Menu and uses a ViewSwitcher to quick turn the exisiting TextView with the
 * Flow's name into an EditText for the user to rename.
 *
 * @param cardPosition position of cardview in adapter
 * @param cardViewClicked the cardview view object clicked
 */// w w  w  .ja v a 2s.c  o  m
private void renameFlow(final int cardPosition, final View cardViewClicked) {
    menuState = AppConstants.MENU_ITEMS_HIDE;
    invalidateOptionsMenu();
    final ViewSwitcher switcher = (ViewSwitcher) cardViewClicked.findViewById(R.id.hub_rename_switcher);
    final EditText rename = (EditText) switcher.findViewById(R.id.hub_item_flow_rename);

    AppUtils.setNameInputFilters(rename);

    rename.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @RequiresApi(api = Build.VERSION_CODES.KITKAT)
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (rename.hasFocus()) {
                showEditPopupWindow(rename, cardViewClicked, switcher, cardPosition);
            }
        }
    });

    switcher.showNext();

    rename.requestFocus();
    /* Forces keyboard */

}