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.dalmasso.ietfsched.ui.ScheduleFragment.java

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

    mWorkspace = (Workspace) root.findViewById(R.id.workspace);

    mTitle = (TextView) root.findViewById(R.id.block_title);

    mLeftIndicator = root.findViewById(R.id.indicator_left);
    mLeftIndicator.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if ((motionEvent.getAction() & MotionEventUtils.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
                mWorkspace.scrollLeft();
                return true;
            }/*from w ww.j a  v  a 2 s .c o  m*/
            return false;
        }
    });
    mLeftIndicator.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            mWorkspace.scrollLeft();
        }
    });

    mRightIndicator = root.findViewById(R.id.indicator_right);
    mRightIndicator.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if ((motionEvent.getAction() & MotionEventUtils.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
                mWorkspace.scrollRight();
                return true;
            }
            return false;
        }
    });
    mRightIndicator.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            mWorkspace.scrollRight();
        }
    });

    for (long day : START_DAYS) {
        setupDay(inflater, day);
    }

    //        setupDay(inflater, TUE_START);
    //        setupDay(inflater, WED_START);

    updateWorkspaceHeader(0);
    mWorkspace.setOnScrollListener(new Workspace.OnScrollListener() {
        public void onScroll(float screenFraction) {
            updateWorkspaceHeader(Math.round(screenFraction));
        }
    }, true);

    return root;
}

From source file:me.albinmathew.celluloid.ui.fragments.MovieDetailFragment.java

public void showReviews(@NonNull List<ReviewResponseBean> reviews) {
    if (reviews.isEmpty()) {
        mReviewsLabel.setVisibility(View.GONE);
        mReviewsView.setVisibility(View.GONE);
    } else {//  w w  w  .  j  a v a  2 s. com
        mReviewsLabel.setVisibility(View.VISIBLE);
        mReviewsView.setVisibility(View.VISIBLE);
        mReviewsView.removeAllViews();
        if (mContext != null && isAdded()) {
            LayoutInflater inflater = getActivity().getLayoutInflater();
            for (ReviewResponseBean review : reviews) {
                ViewGroup reviewContainer = (ViewGroup) inflater.inflate(R.layout.review, mReviewsView, false);
                TextView reviewAuthor = (TextView) reviewContainer.findViewById(R.id.review_author);
                TextView reviewContent = (TextView) reviewContainer.findViewById(R.id.review_content);
                reviewAuthor.setText(review.getAuthor());
                reviewContent.setText(review.getContent());
                reviewAuthor.setPadding(10, 10, 10, 10);
                reviewContent.setPadding(10, 10, 10, 10);
                reviewContent.setOnClickListener(this);
                mReviewsView.addView(reviewContainer);
            }
        }
    }
}

From source file:com.goliathonline.android.kegbot.ui.TagStreamFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null);

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(/*  w w w .ja  v a2s.c o  m*/
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    mLoadingSpinner = root.findViewById(R.id.loading_spinner);
    mWebView = (WebView) root.findViewById(R.id.webview);
    mWebView.setWebViewClient(mWebViewClient);

    mWebView.post(new Runnable() {
        public void run() {
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
            try {
                mWebView.loadUrl(
                        "http://mobile.twitter.com/searches?q=" + URLEncoder.encode(mSearchString, "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                Log.e(TAG, "Could not construct the realtime search URL", e);
            }
        }
    });

    return root;
}

From source file:com.google.android.apps.iosched.ui.TagStreamFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null);

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(//from w ww  .  j  a  v a2s  . c o  m
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    mLoadingSpinner = root.findViewById(R.id.loading_spinner);
    mWebView = (WebView) root.findViewById(R.id.webview);
    mWebView.setWebViewClient(mWebViewClient);

    mWebView.post(new Runnable() {
        public void run() {
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
            try {
                mWebView.loadUrl("http://search.twitter.com/search.html?result_type=recent&q="
                        + URLEncoder.encode(mSearchString, "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                Log.e(TAG, "Could not construct the realtime search URL", e);
            }
        }
    });

    return root;
}

From source file:com.heneryh.aquanotes.ui.WebStreamFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null);

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(// w  w  w  . j  a  va  2  s. co m
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    mLoadingSpinner = root.findViewById(R.id.loading_spinner);
    mWebView = (WebView) root.findViewById(R.id.webview);
    mWebView.setWebViewClient(mWebViewClient);

    mWebView.post(new Runnable() {
        public void run() {
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
            //                    mWebView.loadUrl(
            //                            "http://www.google.com/search?tbs="
            //                            + "mbl%3A1&hl=en&source=hp&biw=1170&bih=668&q="
            //                            + URLEncoder.encode(mSearchString, "UTF-8")
            //                            + "&btnG=Search");
            mWebView.loadUrl("http://reefcentral.com/forums/forumdisplay.php?f=368");
        }
    });

    return root;
}

From source file:android.support.v17.leanback.app.VerticalGridFragment.java

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

    mBrowseFrame = (BrowseFrameLayout) root.findViewById(R.id.browse_frame);
    mBrowseFrame.setOnFocusSearchListener(mOnFocusSearchListener);

    mTitleView = (TitleView) root.findViewById(R.id.browse_title_group);
    mTitleView.setBadgeDrawable(mBadgeDrawable);
    mTitleView.setTitle(mTitle);// ww  w.  j av a2s.  c o m
    if (mSearchAffordanceColorSet) {
        mTitleView.setSearchAffordanceColors(mSearchAffordanceColors);
    }
    if (mExternalOnSearchClickedListener != null) {
        mTitleView.setOnSearchClickedListener(mExternalOnSearchClickedListener);
    }

    mSceneWithTitle = sTransitionHelper.createScene(root, new Runnable() {
        @Override
        public void run() {
            mTitleView.setVisibility(View.VISIBLE);
        }
    });
    mSceneWithoutTitle = sTransitionHelper.createScene(root, new Runnable() {
        @Override
        public void run() {
            mTitleView.setVisibility(View.INVISIBLE);
        }
    });
    Context context = getActivity();
    mTitleUpTransition = sTransitionHelper.loadTransition(context, R.transition.lb_title_out);
    mTitleDownTransition = sTransitionHelper.loadTransition(context, R.transition.lb_title_in);

    return root;
}

From source file:com.infine.android.devoxx.ui.TagStreamFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null);

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(//from w ww.j ava2s  .c  o  m
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    mLoadingSpinner = root.findViewById(R.id.loading_spinner);
    mWebView = (WebView) root.findViewById(R.id.webview);
    mWebView.setWebViewClient(mWebViewClient);

    mWebView.post(new Runnable() {
        public void run() {
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
            try {
                mWebView.loadUrl("https://twitter.com/#!/search/" + URLEncoder.encode(mSearchString, "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                Log.e(TAG, "Could not construct the realtime search URL", e);
            }
        }
    });

    return root;
}

From source file:com.heneryh.aquanotes.ui.TagStreamFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null);

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(/*from   ww w. j  a va 2s .  c  om*/
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    mLoadingSpinner = root.findViewById(R.id.loading_spinner);
    mWebView = (WebView) root.findViewById(R.id.webview);
    mWebView.setWebViewClient(mWebViewClient);

    mWebView.post(new Runnable() {
        public void run() {
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
            try {
                mWebView.loadUrl(
                        "http://www.google.com/search?tbs=" + "mbl%3A1&hl=en&source=hp&biw=1170&bih=668&q="
                                + URLEncoder.encode(mSearchString, "UTF-8") + "&btnG=Search");
            } catch (UnsupportedEncodingException e) {
                Log.e(TAG, "Could not construct the realtime search URL", e);
            }
        }
    });

    return root;
}

From source file:me.albinmathew.celluloid.ui.fragments.MovieDetailFragment.java

public void showTrailers(@NonNull List<VideoResponseBean> trailers) {
    if (trailers.isEmpty()) {
        mTrailerLabel.setVisibility(View.GONE);
        mTrailersView.setVisibility(View.GONE);
        mTrailersScrollView.setVisibility(View.GONE);

    } else {//  ww w .  ja  v  a 2  s  . co  m
        mTrailerLabel.setVisibility(View.VISIBLE);
        mTrailersView.setVisibility(View.VISIBLE);
        mTrailersScrollView.setVisibility(View.VISIBLE);
        mTrailersView.removeAllViews();
        if (mContext != null && isAdded()) {
            LayoutInflater inflater = getActivity().getLayoutInflater();
            Picasso picasso = Picasso.with(getContext());
            shareVideos();
            for (VideoResponseBean trailer : trailers) {
                ViewGroup thumbContainer = (ViewGroup) inflater.inflate(R.layout.video, mTrailersView, false);
                ImageView thumbView = (ImageView) thumbContainer.findViewById(R.id.video_thumb);
                thumbView.setTag(CommonUtil.getUrl(trailer));
                thumbView.requestLayout();
                thumbView.setOnClickListener(this);
                picasso.load(CommonUtil.getThumbnailUrl(trailer))
                        .resizeDimen(R.dimen.video_width, R.dimen.video_height).centerCrop()
                        .placeholder(R.color.cardview_shadow_start_color).into(thumbView);
                mTrailersView.addView(thumbContainer);
            }
        }
    }
}

From source file:com.adithya321.sharesanalysis.fragments.SalesShareFragment.java

@Nullable
@Override/*from   w ww  .jav a 2 s  .co  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_sales, container, false);

    databaseHandler = new DatabaseHandler(getContext());
    salesRecyclerView = (RecyclerView) root.findViewById(R.id.sales_recycler_view);
    setRecyclerViewAdapter();

    FloatingActionButton sellShareFab = (FloatingActionButton) root.findViewById(R.id.sell_share_fab);
    sellShareFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Sell Share Holdings");
            dialog.setContentView(R.layout.dialog_sell_share_holdings);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner);

            ArrayList<String> shares = new ArrayList<>();
            for (Share share : sharesList) {
                shares.add(share.getName());
            }
            ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(),
                    android.R.layout.simple_spinner_item, shares);
            spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(spinnerAdapter);

            Calendar calendar = Calendar.getInstance();
            year_start = calendar.get(Calendar.YEAR);
            month_start = calendar.get(Calendar.MONTH) + 1;
            day_start = calendar.get(Calendar.DAY_OF_MONTH);
            final Button selectDate = (Button) dialog.findViewById(R.id.select_date);
            selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/")
                    .append(year_start));
            selectDate.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start,
                            month_start - 1, day_start);
                    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            selectDate.setText(new StringBuilder().append(day_start).append("/")
                                    .append(month_start).append("/").append(year_start));
                        }
                    });
                    dialog.show();
                }
            });

            Button sellShareBtn = (Button) dialog.findViewById(R.id.sell_share_btn);
            sellShareBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Purchase purchase = new Purchase();
                    purchase.setId(databaseHandler.getNextKey("purchase"));
                    purchase.setName(spinner.getSelectedItem().toString());

                    String stringStartDate = year_start + " " + month_start + " " + day_start;
                    DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH);
                    try {
                        Date date = format.parse(stringStartDate);
                        purchase.setDate(date);
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares);
                    try {
                        purchase.setQuantity(Integer.parseInt(quantity.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText price = (EditText) dialog.findViewById(R.id.selling_price);
                    try {
                        purchase.setPrice(Double.parseDouble(price.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Selling Price", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    purchase.setType("sell");
                    databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase);
                    setRecyclerViewAdapter();
                    dialog.dismiss();
                }
            });
        }
    });

    return root;
}