Example usage for android.view ViewGroup findViewById

List of usage examples for android.view ViewGroup findViewById

Introduction

In this page you can find the example usage for android.view ViewGroup 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:org.ayo.robot.anim.transitioneverywhere.InterpolatorDurationStartDelaySample.java

@Nullable
@Override//from  w  w  w .  j  a  va2 s  . c o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_interpolator, container, false);

    final ViewGroup transitionsContainer = (ViewGroup) view.findViewById(R.id.transitions_container);
    final View button = transitionsContainer.findViewById(R.id.button);

    button.setOnClickListener(new View.OnClickListener() {

        boolean mToRightAnimation;

        @Override
        public void onClick(View v) {
            mToRightAnimation = !mToRightAnimation;

            Transition transition = new ChangeBounds();
            transition.setDuration(mToRightAnimation ? 700 : 300);
            transition.setInterpolator(
                    mToRightAnimation ? new FastOutSlowInInterpolator() : new AccelerateInterpolator());
            transition.setStartDelay(mToRightAnimation ? 0 : 500);
            TransitionManager.beginDelayedTransition(transitionsContainer, transition);

            FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) button.getLayoutParams();
            params.gravity = mToRightAnimation ? (Gravity.RIGHT | Gravity.TOP) : (Gravity.LEFT | Gravity.TOP);
            button.setLayoutParams(params);
        }

    });

    return view;
}

From source file:com.example.testtab.fragment.GalleryPageFragment.java

public void setGallery(ViewGroup rootView) {
    this.mGallery = (Gallery) rootView.findViewById(R.id.gallery);
    this.mImageList = prepareImageList();
    this.mImageAdapter = new ImageAdapter(mContext, this.mImageList);
    this.mGallery.setAdapter(this.mImageAdapter);
    this.mGallery.setOnItemClickListener(this);
    this.mGallery.setOnItemSelectedListener(this);
}

From source file:com.hacktx.android.fragments.AnnouncementFragment.java

private void setupRecyclerView(ViewGroup root) {
    mRecyclerView = (RecyclerView) root.findViewById(R.id.announcement_recyclerview);
    mRecyclerView.setHasFixedSize(true);

    // use a linear layout manager
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);

    mRecyclerView.addItemDecoration(new SpacesItemDecoration(20));

    // specify an adapter (see also next example)
    mAdapter = new AnnouncementsRecyclerView(announcements);
    mRecyclerView.setAdapter(mAdapter);/*w  ww . j  a  v a  2  s  .  c  om*/
}

From source file:edu.ucuccs.ucufreshmenguide.SturOrgListAcademicViewPager.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_listview, container, false);

    final ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
    setData(listView);/* w  w w  .j  a  v a2 s  .co m*/

    Fragment parentFragment = getParentFragment();
    ViewGroup viewGroup = (ViewGroup) parentFragment.getView();
    if (viewGroup != null) {
        listView.setTouchInterceptionViewGroup((ViewGroup) viewGroup.findViewById(R.id.container));
        if (parentFragment instanceof ObservableScrollViewCallbacks) {
            listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentFragment);
        }
    }
    return view;
}

From source file:com.frostox.calculo.fragments.ScreenSlidePageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false);

    WebView webView = (WebView) rootView.findViewById(R.id.web);

    webView.loadUrl(getString(R.string.base_url_extraclass) + "uploads/" + noteid);

    return rootView;
}

From source file:com.horizonx.simplesaving.ScreenSlidePageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false);
    ImageView imageView = (ImageView) rootView.findViewById(R.id.tutorial_page);
    imageView.setImageResource((Integer) ScreenSlideActivity.getPageElement(mPageNumber));

    return rootView;

}

From source file:com.example.android.scrolltricks.StickyFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_content, container, false);

    mObservableScrollView = (ObservableScrollView) rootView.findViewById(R.id.scroll_view);
    mObservableScrollView.setCallbacks(this);

    mStickyView = (TextView) rootView.findViewById(R.id.sticky);
    mStickyView.setText(R.string.sticky_item);
    mPlaceholderView = rootView.findViewById(R.id.placeholder);

    mObservableScrollView.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override/*from w w w .  j  av  a 2  s.c  o m*/
                public void onGlobalLayout() {
                    onScrollChanged(mObservableScrollView.getScrollY());
                }
            });

    return rootView;
}

From source file:com.racoon.ampdroid.views.SettingsView.java

@SuppressLint("InflateParams")
@Override/*w  w w  . ja v a 2  s  .c  o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    controller = Controller.getInstance();
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.settings, null);
    final EditText editServer = (EditText) root.findViewById(R.id.settingsServer);
    final EditText editUser = (EditText) root.findViewById(R.id.settingsUser);
    final EditText editPassword = (EditText) root.findViewById(R.id.settingsPassword);
    final TextView connectionInfo = (TextView) root.findViewById(R.id.settingsConnectionInfo);
    final TextView connectionInfoText = (TextView) root.findViewById(R.id.settingsConnectionInfoText);
    if (controller.getServer() != null) {
        if (!controller.getServer().getHost().equals("")) {
            editServer.setText(controller.getServer().getHost());
        }
        if (!controller.getServer().getUser().equals("")) {
            editUser.setText(controller.getServer().getUser());
        }
        if (!controller.getServer().getPassword().equals("")) {
            editPassword.setText(controller.getServer().getPassword());
        }
        if (controller.getServer().isConnected(controller.isOnline(root.getContext()))) {
            connectionInfoText.setText(R.string.settingsExpireText);
            connectionInfo.setText(controller.getServer().getAmpacheConnection().getSessionExpireString());
        }
    }
    setHasOptionsMenu(true);
    return root;
}

From source file:com.example.android.supportv7.widget.PopupMenuActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.popup_menu_activity);

    mDateFormat = new SimpleDateFormat("HH:mm:ss.SSS");

    final ViewGroup container = findViewById(R.id.container);
    mLog = (TextView) container.findViewById(R.id.log);

    final SwitchCompat elevationToggle = (SwitchCompat) container.findViewById(R.id.elevation_toggle);
    final Button button = (Button) container.findViewById(R.id.test_button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override//from   w  ww. j  av  a 2  s.co  m
        public void onClick(View v) {
            // Do we need to use a custom style that removes elevation?
            boolean useDefaultElevation = elevationToggle.isChecked();

            PopupMenu popupMenu = null;
            if (useDefaultElevation) {
                popupMenu = new PopupMenu(container.getContext(), button);
            } else {
                popupMenu = new PopupMenu(container.getContext(), button, Gravity.NO_GRAVITY, 0,
                        R.style.CustomPopupNoElevation);
            }

            final MenuInflater menuInflater = popupMenu.getMenuInflater();
            menuInflater.inflate(R.menu.popup_menu, popupMenu.getMenu());
            final MenuItem editItem = popupMenu.getMenu().findItem(R.id.action_edit);
            MenuItemCompat.setContentDescription(editItem, getString(R.string.popup_menu_edit_description));
            MenuItemCompat.setTooltipText(editItem, getString(R.string.popup_menu_edit_tooltip));

            // Register a listener to be notified when a menu item in our popup menu has
            // been clicked.
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    addToLog("Item '" + item.getTitle() + "' clicked");
                    return true;
                }
            });

            // Register a listener to be notified when our popup menu is dismissed.
            popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
                @Override
                public void onDismiss(PopupMenu menu) {
                    addToLog("Popup menu dismissed");
                }
            });

            // Show the popup menu
            popupMenu.show();
        }
    });
}

From source file:org.ciasaboark.tacere.activity.fragment.TutorialWelcomeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(layout, container, false);

    Quote quote = getRandomQuote();/*from  w w  w.ja  v  a  2  s.  c o  m*/
    TextView quoteText = (TextView) rootView.findViewById(R.id.quote_text);
    TextView quoteAuthor = (TextView) rootView.findViewById(R.id.quote_author);
    TextView quoteSource = (TextView) rootView.findViewById(R.id.quote_source);
    quoteText.setText("\"" + quote.getQuote() + "\"");
    quoteAuthor.setText("-" + quote.author);
    quoteSource.setText(quote.getSource());

    return rootView;
}