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:com.eutectoid.dosomething.picker.PickerFragment.java

private void inflateTitleBar(ViewGroup view) {
    ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub);
    if (stub != null) {
        View titleBar = stub.inflate();

        final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar);
        listView.setLayoutParams(layoutParams);

        if (titleBarBackground != null) {
            titleBar.setBackgroundDrawable(titleBarBackground);
        }//from   w ww.j a  v a2  s. c  o  m

        doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button);
        if (doneButton != null) {
            doneButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    logAppEvents(true);
                    appEventsLogged = true;

                    if (onDoneButtonClickedListener != null) {
                        onDoneButtonClickedListener.onDoneButtonClicked(PickerFragment.this);
                    }
                }
            });

            if (getDoneButtonText() != null) {
                doneButton.setText(getDoneButtonText());
            }

            if (doneButtonBackground != null) {
                doneButton.setBackgroundDrawable(doneButtonBackground);
            }
        }

        titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title);
        if (titleTextView != null) {
            if (getTitleText() != null) {
                titleTextView.setText(getTitleText());
            }
        }
    }
}

From source file:net.olejon.mdapp.MedicationFelleskatalogenFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override/*from w  w w.ja  v  a2  s.  c  o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_medication_felleskatalogen, container,
            false);

    // Activity
    final Activity activity = getActivity();

    // Context
    final Context context = activity.getApplicationContext();

    // Tools
    final MyTools mTools = new MyTools(context);

    // Arguments
    Bundle bundle = getArguments();

    final String pageUri = bundle.getString("uri");

    // Progress bar
    final ProgressBar progressBar = (ProgressBar) activity
            .findViewById(R.id.medication_toolbar_progressbar_horizontal);

    // Toolbar
    final LinearLayout toolbarSearchLayout = (LinearLayout) activity
            .findViewById(R.id.medication_toolbar_search_layout);
    final EditText toolbarSearchEditText = (EditText) activity.findViewById(R.id.medication_toolbar_search);

    // Web view
    WEBVIEW = (WebView) viewGroup.findViewById(R.id.medication_felleskatalogen_content);

    WebSettings webSettings = WEBVIEW.getSettings();
    webSettings.setJavaScriptEnabled(true);

    WEBVIEW.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (!mTools.isDeviceConnected()) {
                mTools.showToast(getString(R.string.device_not_connected), 0);
                return true;
            } else if (url.matches("^https?://.*?\\.pdf$")) {
                mTools.downloadFile(view.getTitle(), url);
                return true;
            }

            return false;
        }
    });

    WEBVIEW.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress == 100) {
                progressBar.setVisibility(View.INVISIBLE);
            } else {
                progressBar.setVisibility(View.VISIBLE);
                progressBar.setProgress(newProgress);

                toolbarSearchLayout.setVisibility(View.GONE);
                toolbarSearchEditText.setText("");
            }
        }
    });

    if (savedInstanceState == null) {
        WEBVIEW.loadUrl(pageUri);
    } else {
        WEBVIEW.restoreState(savedInstanceState);
    }

    return viewGroup;
}

From source file:com.github.michalbednarski.intentslab.editor.IntentGeneralFragment.java

public void addCategoryTextField(String category) {
    final ViewGroup row = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.category_row,
            mCategoriesContainer, false);
    final TextView textField = ((TextView) row.findViewById(R.id.categoryText));
    textField.setText(category);//from w ww  .j  a va  2  s.  com
    row.findViewById(R.id.row_remove).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mCategoriesContainer.removeView(row);
            mCategoryTextInputs.remove(textField);
        }
    });
    mCategoriesContainer.addView(row);
    mCategoryTextInputs.add(textField);
}

From source file:de.gebatzens.sia.SettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(SIAApp.SIA_APP.school.getTheme());

    changed = false;// w  w  w. j a va 2s.  co  m
    recreate = false;

    super.onCreate(savedInstanceState);

    ViewGroup contentView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.activity_settings,
            new LinearLayout(this), false);

    setContentView(contentView);

    if (savedInstanceState != null) {
        changed = savedInstanceState.getBoolean("s_changed");
        recreate = savedInstanceState.getBoolean("s_recreate");
    } else {
        frag = new CustomPreferenceFragment();
        getSupportFragmentManager().beginTransaction().replace(R.id.content_wrapper, frag, "settings_frag")
                .commit();
    }

    mToolBar = (Toolbar) contentView.findViewById(R.id.toolbar);
    mToolBar.setTitle(getTitle());
    mToolBar.setNavigationIcon(R.drawable.ic_arrow_back);
    mToolBar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

}

From source file:com.aniruddhc.acemusic.player.FoldersFragment.FilesFoldersFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_folders, container, false);
    mContext = getActivity().getApplicationContext();
    mFilesFoldersFragment = this;
    mApp = (Common) mContext;/*from  w ww .j  a v  a  2s  .c o m*/
    mFolderStateMap = new HashMap<String, Parcelable>();

    //Set the hidden files flag.
    SHOW_HIDDEN_FILES = mApp.getSharedPreferences().getBoolean("SHOW_HIDDEN_FILES", false);

    listView = (ListView) rootView.findViewById(R.id.folders_list_view);
    listView.setFastScrollEnabled(true);
    listView.setVisibility(View.INVISIBLE);

    //Set the background color based on the theme.
    rootView.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));

    //Apply the ListView params.
    //Apply the ListViews' dividers.
    if (mApp.getCurrentTheme() == Common.DARK_THEME) {
        listView.setDivider(mContext.getResources().getDrawable(R.drawable.icon_list_divider));
    } else {
        listView.setDivider(mContext.getResources().getDrawable(R.drawable.icon_list_divider_light));
    }

    listView.setDividerHeight(1);

    //KitKat translucent navigation/status bar.
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
        int topPadding = Common.getStatusBarHeight(mContext);

        //Calculate navigation bar height.
        int navigationBarHeight = 0;
        int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
        if (resourceId > 0) {
            navigationBarHeight = getResources().getDimensionPixelSize(resourceId);
        }

        if (rootView != null) {
            rootView.setPadding(0, topPadding, 0, 0);
        }

        listView.setClipToPadding(false);
        listView.setPadding(0, 0, 0, navigationBarHeight);
    }

    rootDir = mApp.getSharedPreferences().getString("DEFAULT_FOLDER",
            Environment.getExternalStorageDirectory().getPath());
    currentDir = rootDir;
    mHandler.postDelayed(new Runnable() {

        @Override
        public void run() {
            slideUpListView();
        }

    }, 250);
    return rootView;
}

From source file:com.eutectoid.dosomething.picker.PickerFragment.java

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

    listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override/*w ww.ja v  a 2s.  c  o m*/
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            onListItemClick((ListView) parent, v, position);
        }
    });
    listView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            // We don't actually do anything differently on long-clicks, but setting the listener
            // enables the selector transition that we have for visual consistency with the
            // Facebook app's pickers.
            return false;
        }
    });
    listView.setOnScrollListener(onScrollListener);

    activityCircle = (ProgressBar) view.findViewById(R.id.com_facebook_picker_activity_circle);

    setupViews(view);

    listView.setAdapter(adapter);

    return view;
}

From source file:android.support.v7.app.AlertController.java

private void setupView() {
    final View parentPanel = mWindow.findViewById(R.id.parentPanel);
    final View defaultTopPanel = parentPanel.findViewById(R.id.topPanel);
    final View defaultContentPanel = parentPanel.findViewById(R.id.contentPanel);
    final View defaultButtonPanel = parentPanel.findViewById(R.id.buttonPanel);

    // Install custom content before setting up the title or buttons so
    // that we can handle panel overrides.
    final ViewGroup customPanel = (ViewGroup) parentPanel.findViewById(R.id.customPanel);
    setupCustomContent(customPanel);//from w w  w  .  j  a va2 s  .  c  o m

    final View customTopPanel = customPanel.findViewById(R.id.topPanel);
    final View customContentPanel = customPanel.findViewById(R.id.contentPanel);
    final View customButtonPanel = customPanel.findViewById(R.id.buttonPanel);

    // Resolve the correct panels and remove the defaults, if needed.
    final ViewGroup topPanel = resolvePanel(customTopPanel, defaultTopPanel);
    final ViewGroup contentPanel = resolvePanel(customContentPanel, defaultContentPanel);
    final ViewGroup buttonPanel = resolvePanel(customButtonPanel, defaultButtonPanel);

    setupContent(contentPanel);
    setupButtons(buttonPanel);
    setupTitle(topPanel);

    final boolean hasCustomPanel = customPanel != null && customPanel.getVisibility() != View.GONE;
    final boolean hasTopPanel = topPanel != null && topPanel.getVisibility() != View.GONE;
    final boolean hasButtonPanel = buttonPanel != null && buttonPanel.getVisibility() != View.GONE;

    // Only display the text spacer if we don't have buttons.
    if (!hasButtonPanel) {
        if (contentPanel != null) {
            final View spacer = contentPanel.findViewById(R.id.textSpacerNoButtons);
            if (spacer != null) {
                spacer.setVisibility(View.VISIBLE);
            }
        }
    }

    if (hasTopPanel) {
        // Only clip scrolling content to padding if we have a title.
        if (mScrollView != null) {
            mScrollView.setClipToPadding(true);
        }
    }

    // Update scroll indicators as needed.
    if (!hasCustomPanel) {
        final View content = mListView != null ? mListView : mScrollView;
        if (content != null) {
            final int indicators = (hasTopPanel ? ViewCompat.SCROLL_INDICATOR_TOP : 0)
                    | (hasButtonPanel ? ViewCompat.SCROLL_INDICATOR_BOTTOM : 0);
            setScrollIndicators(contentPanel, content, indicators,
                    ViewCompat.SCROLL_INDICATOR_TOP | ViewCompat.SCROLL_INDICATOR_BOTTOM);
        }
    }

    final ListView listView = mListView;
    if (listView != null && mAdapter != null) {
        listView.setAdapter(mAdapter);
        final int checkedItem = mCheckedItem;
        if (checkedItem > -1) {
            listView.setItemChecked(checkedItem, true);
            listView.setSelection(checkedItem);
        }
    }
}

From source file:com.aretha.slidemenu.SlideMenu.java

/**
 * Resolve the attribute slideMode/*from  ww w .j a  v  a  2s.  co m*/
 */
protected void resolveSlideMode() {
    final ViewGroup decorView = (ViewGroup) getRootView();
    final ViewGroup contentContainer = (ViewGroup) decorView.findViewById(android.R.id.content);
    final View content = mContent;
    if (null == decorView || null == content || 0 == getChildCount()) {
        return;
    }

    TypedValue value = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.windowBackground, value, true);

    switch (mSlideMode) {
    case MODE_SLIDE_WINDOW: {
        // remove this view from parent
        removeViewFromParent(this);
        // copy the layoutparams of content
        LayoutParams contentLayoutParams = new LayoutParams(content.getLayoutParams());
        // remove content view from this view
        removeViewFromParent(content);
        // add content to layout root view
        contentContainer.addView(content);

        // get window with ActionBar
        View decorChild = decorView.getChildAt(0);
        decorChild.setBackgroundResource(0);
        removeViewFromParent(decorChild);
        addView(decorChild, contentLayoutParams);

        // add this view to root view
        decorView.addView(this);
        setBackgroundResource(value.resourceId);
    }
        break;
    case MODE_SLIDE_CONTENT: {
        // remove this view from decor view
        setBackgroundResource(0);
        removeViewFromParent(this);
        // get the origin content view from the content wrapper
        View originContent = contentContainer.getChildAt(0);
        // this is the decor child remove from decor view
        View decorChild = mContent;
        LayoutParams layoutParams = (LayoutParams) decorChild.getLayoutParams();
        // remove the origin content from content wrapper
        removeViewFromParent(originContent);
        // remove decor child from this view
        removeViewFromParent(decorChild);
        // restore the decor child to decor view
        decorChild.setBackgroundResource(value.resourceId);
        decorView.addView(decorChild);
        // add this view to content wrapper
        contentContainer.addView(this);
        // add the origin content to this view
        addView(originContent, layoutParams);
    }
        break;
    }
}

From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java

private void updateContentFromGG(Match data) {

    if (data == null) {
        Toast.makeText(this, "Network Connection issues", Toast.LENGTH_SHORT).show();
        return;//  w  w  w  .j a  va2  s .  com
    }

    if (Long.parseLong(dateTime) < TimeUtils.getUTCTime()) {
        mMatchScoreView.setText(data.teamOne.score + " : " + data.teamTwo.score);
    } else {
        mMatchScoreView.setText(" vs ");
    }

    if (data.livestreams != null && data.livestreams.length != 0) {
        final ViewGroup livestreamsCard = (ViewGroup) getLayoutInflater().inflate(R.layout.card_livestream,
                mDetailsContainer, false);
        final ViewGroup livestreamsBlock = (ViewGroup) livestreamsCard
                .findViewById(R.id.card_livestreams_block);
        for (int i = 0; i < data.livestreams.length; i++) {
            if (data.livestreams[i].url == null) {
                continue;
            }
            final View livestreamItem = getLayoutInflater().inflate(R.layout.livestream_detail,
                    livestreamsBlock, false);
            final TextView livestreamNameView = (TextView) livestreamItem
                    .findViewById(R.id.livestream_name_view);
            final TextView livestreamServiceView = (TextView) livestreamItem
                    .findViewById(R.id.livestream_service_view);

            final Uri livestreamUri = Uri.parse(data.livestreams[i].url);

            livestreamNameView
                    .setText(data.livestreams[i].language.toUpperCase() + " - " + data.livestreams[i].title);
            livestreamServiceView
                    .setText(data.livestreams[i].url.contains("twitch.tv") ? "Twitch.tv" : "DailyMotion");

            livestreamItem.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent viewLivestreamIntent = new Intent(Intent.ACTION_VIEW, livestreamUri);
                    startActivity(viewLivestreamIntent);
                }
            });

            livestreamsBlock.addView(livestreamItem);

            final View divider = getLayoutInflater().inflate(R.layout.divider, livestreamsBlock, false);
            livestreamsBlock.addView(divider);
        }

        mDetailsContainer.addView(livestreamsCard, 1);

    }

    if (data.vods != null && data.vods.length != 0) {
        final ViewGroup vodsCard = (ViewGroup) getLayoutInflater().inflate(R.layout.card_vods,
                mDetailsContainer, false);
        final ViewGroup vodsBlock = (ViewGroup) vodsCard.findViewById(R.id.card_vods_block);
        for (int i = 0; i < data.vods.length; i++) {
            final TextView vodsItem = (TextView) getLayoutInflater().inflate(R.layout.vod_detail, vodsBlock,
                    false);

            vodsItem.setText(data.vods[i].vodDesc);

            final Uri vodUri = Uri.parse(data.vods[i].vodUrl);

            vodsItem.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent viewVodIntent = new Intent(Intent.ACTION_VIEW, vodUri);
                    startActivity(viewVodIntent);
                }
            });

            vodsBlock.addView(vodsItem);

            final View divider = getLayoutInflater().inflate(R.layout.divider, vodsBlock, false);
            vodsBlock.addView(divider);
        }

        mDetailsContainer.addView(vodsCard, 2);

    }

    data.teamOne.flagUrl = teamLeftFlagUrl;
    data.teamTwo.flagUrl = teamRightFlagUrl;
    data.teamOne.name = teamLeftName;
    data.teamTwo.name = teamRightName;

    mTeamCardOne = makeTeamView(data.teamOne, mDetailsContainer);
    mTeamCardTwo = makeTeamView(data.teamTwo, mDetailsContainer);

    mDetailsContainer.addView(mTeamCardOne);
    mDetailsContainer.addView(mTeamCardTwo);

    mMatchTeamOneImageView.setClickable(true);
    mMatchTeamTwoImageView.setClickable(true);

    mMatchTeamOneImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mScrollView.smoothScrollTo(0,
                    Math.round(mTeamCardOne.getY() + mTeamCardOne.getHeight() - mHeaderHeightPixels));
        }
    });

    mMatchTeamTwoImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mScrollView.smoothScrollTo(0,
                    Math.round(mTeamCardTwo.getY() + mTeamCardTwo.getHeight() - mHeaderHeightPixels));
        }
    });

    final ViewGroup extrasCard = (ViewGroup) getLayoutInflater().inflate(R.layout.card_links, mDetailsContainer,
            false);

    final ViewGroup extrasBlock = (ViewGroup) extrasCard.findViewById(R.id.card_links_block);

    final TextView extrasItem = (TextView) getLayoutInflater().inflate(R.layout.link_item, extrasBlock, false);

    extrasItem.setText("GosuGamers Match Page");

    extrasItem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent viewGGNetMatchPage = new Intent(Intent.ACTION_VIEW, Uri.parse(mUrl));
            startActivity(viewGGNetMatchPage);
        }
    });

    extrasBlock.addView(extrasItem);

    mDetailsContainer.addView(extrasCard);

    mMatchViewContainer.setBackground(null);
    //getWindow().setBackgroundDrawable(null);

    mDetailsContainer.animate().translationY(0).setDuration(350).setInterpolator(new DecelerateInterpolator())
            .start();

}

From source file:com.ncode.android.apps.schedo.ui.EventsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_events, container, false);
    mCollectionView = (CollectionView) root.findViewById(R.id.events_collection_view);
    mPreloader = new Preloader(ROWS_TO_PRELOAD);
    mCollectionView.setOnScrollListener(mPreloader);
    mEmptyView = (TextView) root.findViewById(R.id.empty_text);
    mLoadingView = root.findViewById(R.id.loading);
    return root;//from w w w.j ava2  s.co  m
}