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:hkhc.electricspock.sample.SupportMainFragment.java

@Nullable
@Override//from  ww w . j ava 2s.c o m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    ViewGroup vg = (ViewGroup) inflater.inflate(R.layout.fragment_main, null);
    helloWorldText = (TextView) vg.findViewById(R.id.text);

    // Create a banner ad. The ad size and ad unit ID must be set before calling loadAd.
    AdView mAdView = new AdView(getActivity());
    mAdView.setAdSize(AdSize.SMART_BANNER);
    mAdView.setAdUnitId("myAdUnitId");

    // Create an ad request.
    AdRequest.Builder adRequestBuilder = new AdRequest.Builder();

    // Optionally populate the ad request builder.
    adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);

    // Add the AdView to the view hierarchy.
    vg.addView(mAdView);

    // Start loading the ad.
    // **** it will freeze Robolectric test
    // **** in practise we shall decouple the loadAd method from
    // the class under test
    //        mAdView.loadAd(adRequestBuilder.build());

    return vg;

}

From source file:com.paras.amazonadvertice.ModelessInterstitialFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setRetainInstance(true);/* www . j a  v  a  2  s . c  o  m*/
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.modeless_fragment, container, false);
    final LinearLayout layout = (LinearLayout) rootView.findViewById(R.id.modeless_layout);
    // ensure the parent of the ad layout is the layout for this fragment
    if (this.adContainerLayout.getParent() != null && !this.adContainerLayout.getParent().equals(layout)) {
        ((ViewGroup) this.adContainerLayout.getParent()).removeView(this.adContainerLayout);
    }
    layout.addView(this.adContainerLayout, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    return rootView;
}

From source file:org.ayo.robot.anim.transitioneverywhere.SlideSample.java

@Nullable
@Override//from   w  w  w .j  a v  a 2  s .co m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_slide, container, false);

    final ViewGroup transitionsContainer = (ViewGroup) view.findViewById(R.id.transitions_container);
    final TextView text = (TextView) transitionsContainer.findViewById(R.id.text);

    transitionsContainer.findViewById(R.id.button).setOnClickListener(new VisibleToggleClickListener() {
        @Override
        protected void changeVisibility(boolean visible) {
            TransitionManager.beginDelayedTransition(transitionsContainer, new Slide(Gravity.RIGHT));
            text.setVisibility(visible ? View.VISIBLE : View.GONE);
        }
    });

    return view;
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.SponsorBannerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_sponsor_banner, null);
    mBanner = (SponsorBanner) rootView.findViewById(R.id.sponsor_banner);
    return rootView;
}

From source file:net.clcworld.thermometer.setuppager.Page03Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.page_03, null);
    final EditText id = (EditText) root.findViewById(R.id.patientId);

    final Activity parent = this.getActivity();

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(parent);
    id.setText(prefs.getString("ID", ""));

    Button okButton = (Button) root.findViewById(R.id.ok);
    okButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Editor editor = prefs.edit();
            String patientId = id.getText().toString();
            if (patientId.length() > 0) {
                editor.putString("ID", patientId);
                editor.putBoolean("ISFIRSTRUN", false);
                editor.commit();/* w w  w .jav  a2s.com*/
                AlarmScheduler.setupOneTimeAlarm(parent, System.currentTimeMillis() + 100);
                Toast.makeText(parent, R.string.patientidsaved, Toast.LENGTH_LONG).show();
                parent.finish();
            }
        }
    });

    return root;
}

From source file:com.hhs.hfnavigator.slidingtabs.schedules.MidRegFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null);

    progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress);

    swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe);
    swipeRefreshLayout.setEnabled(false);
    progressWheel.spin();//from   www .  j ava 2s  .c  o m
    final WebView webView = (WebView) root.findViewById(R.id.webView);
    if (webView != null) {
        webView.setWebViewClient(new WebViewClient() {

            public void onPageFinished(WebView view, String url) {
                progressWheel.stopSpinning();
            }
        });
        webView.loadUrl("https://docs.google.com/document/d/1FEFRSCql8AXKBsVoiawX9E087oaPbcQh-f-Ou4yKaIE/pub");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);
    }
    return root;
}

From source file:com.hhs.hfnavigator.slidingtabs.tools.PortalFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null);

    progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress);

    swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe);
    swipeRefreshLayout.setEnabled(false);
    progressWheel.spin();/* w w w .ja v  a2s  . c  o m*/
    final WebView webView = (WebView) root.findViewById(R.id.webView);
    if (webView != null) {
        webView.setWebViewClient(new WebViewClient() {

            public void onPageFinished(WebView view, String url) {
                progressWheel.stopSpinning();
            }
        });
        webView.loadUrl("https://harborfieldscsd.esboces.org/campus/portal/harborfields.jsp");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);
    }
    return root;
}

From source file:com.hhs.hfnavigator.slidingtabs.hhs.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null);

    progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress);

    swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe);
    swipeRefreshLayout.setEnabled(false);
    progressWheel.spin();/*  w ww.  j  a  va 2  s . c  om*/
    final WebView webView = (WebView) root.findViewById(R.id.webView);
    if (webView != null) {
        webView.setWebViewClient(new WebViewClient() {

            public void onPageFinished(WebView view, String url) {
                progressWheel.stopSpinning();
            }
        });
        webView.loadUrl("http://www.harborfieldscsd.net/our_schools/harborfields_high_school");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);
    }
    return root;
}

From source file:com.hhs.hfnavigator.slidingtabs.home.PollsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null);

    progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress);

    swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe);
    swipeRefreshLayout.setEnabled(false);
    progressWheel.spin();/*from   www .  j  ava  2 s. c om*/
    final WebView webView = (WebView) root.findViewById(R.id.webView);
    if (webView != null) {
        webView.setWebViewClient(new WebViewClient() {

            public void onPageFinished(WebView view, String url) {
                progressWheel.stopSpinning();
            }
        });
        webView.loadUrl("https://docs.google.com/document/d/1Y8c9GwN0nkRBRHau1SCRrvAmRK1LQiV7Omn13KsMMqc/pub");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setDisplayZoomControls(false);
    }
    return root;
}

From source file:angeloid.sopiane.vegaphoneinfo.SwipeyTabFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_swipeytab, null);
    final String title = getArguments().getString("title");
    ((TextView) root.findViewById(R.id.text)).setText(title);
    return root;/*from w  w w.  j a  v a2 s .  c  o  m*/
}