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:jahirfiquitiva.iconshowcase.fragments.CreditsFragment.java

private void setupViews(final ViewGroup layout) {

    final int light = ContextCompat.getColor(context, R.color.drawable_tint_dark);
    final int dark = ContextCompat.getColor(context, R.color.drawable_tint_light);

    Drawable collaboratorsIcon = ColorUtils.getTintedIcon(context, R.drawable.ic_code,
            ThemeUtils.darkTheme ? light : dark);

    Drawable libs = ColorUtils.getTintedIcon(context, R.drawable.ic_libraries,
            ThemeUtils.darkTheme ? light : dark);

    Drawable sherryIcon = ColorUtils.getTintedIcon(context, R.drawable.ic_award,
            ThemeUtils.darkTheme ? light : dark);

    Drawable uiCollaboratorsIcon = ColorUtils.getTintedIcon(context, R.drawable.ic_design,
            ThemeUtils.darkTheme ? light : dark);

    Drawable translators = ColorUtils.getTintedIcon(context, R.drawable.ic_translate,
            ThemeUtils.darkTheme ? light : dark);

    ImageView libsIcon = (ImageView) layout.findViewById(R.id.icon_libs);
    ImageView collaboratorsIV = (ImageView) layout.findViewById(R.id.icon_collaborators);
    ImageView sherryIV = (ImageView) layout.findViewById(R.id.icon_sherry);
    ImageView uiCollaboratorsIV = (ImageView) layout.findViewById(R.id.icon_ui_design);
    ImageView translatorsIV = (ImageView) layout.findViewById(R.id.icon_translators);

    libsIcon.setImageDrawable(libs);/*from  w w  w.j  a  v a  2 s .co m*/
    collaboratorsIV.setImageDrawable(collaboratorsIcon);
    sherryIV.setImageDrawable(sherryIcon);
    uiCollaboratorsIV.setImageDrawable(uiCollaboratorsIcon);
    translatorsIV.setImageDrawable(translators);

    AppCompatButton emailBtn = (AppCompatButton) layout.findViewById(R.id.send_email_btn);
    emailBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Utils.sendEmailWithDeviceInfo(context);
        }
    });

    AppCompatButton websiteBtn = (AppCompatButton) layout.findViewById(R.id.website_btn);
    if (YOU_HAVE_WEBSITE) {
        websiteBtn.setText(Utils.getStringFromResources(context, R.string.visit_website));
    } else {
        websiteBtn.setText(Utils.getStringFromResources(context, R.string.more));
    }
    websiteBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (YOU_HAVE_WEBSITE) {
                Utils.openLinkInChromeCustomTab(context,
                        getResources().getString(R.string.iconpack_author_website));
            } else {
                ISDialogs.showDesignerLinksDialog(context, designerLinks);
            }
        }
    });

    AppCompatButton googleBtn = (AppCompatButton) layout.findViewById(R.id.googleplus_btn);
    googleBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Utils.openLinkInChromeCustomTab(context, getResources().getString(R.string.iconpack_author_gplus));
        }
    });
}

From source file:heartware.com.FB_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/*from www. ja v  a  2  s  .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 fb_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 setupButtons(ViewGroup buttonPanel) {
    int BIT_BUTTON_POSITIVE = 1;
    int BIT_BUTTON_NEGATIVE = 2;
    int BIT_BUTTON_NEUTRAL = 4;
    int whichButtons = 0;
    mButtonPositive = (Button) buttonPanel.findViewById(android.R.id.button1);
    mButtonPositive.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonPositiveText)) {
        mButtonPositive.setVisibility(View.GONE);
    } else {//from   w  w  w.j  a v a  2  s . c  om
        mButtonPositive.setText(mButtonPositiveText);
        mButtonPositive.setVisibility(View.VISIBLE);
        whichButtons = whichButtons | BIT_BUTTON_POSITIVE;
    }

    mButtonNegative = (Button) buttonPanel.findViewById(android.R.id.button2);
    mButtonNegative.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonNegativeText)) {
        mButtonNegative.setVisibility(View.GONE);
    } else {
        mButtonNegative.setText(mButtonNegativeText);
        mButtonNegative.setVisibility(View.VISIBLE);

        whichButtons = whichButtons | BIT_BUTTON_NEGATIVE;
    }

    mButtonNeutral = (Button) buttonPanel.findViewById(android.R.id.button3);
    mButtonNeutral.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonNeutralText)) {
        mButtonNeutral.setVisibility(View.GONE);
    } else {
        mButtonNeutral.setText(mButtonNeutralText);
        mButtonNeutral.setVisibility(View.VISIBLE);

        whichButtons = whichButtons | BIT_BUTTON_NEUTRAL;
    }

    final boolean hasButtons = whichButtons != 0;
    if (!hasButtons) {
        buttonPanel.setVisibility(View.GONE);
    }
}

From source file:com.syncedsynapse.kore2.ui.hosts.HostListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    context = inflater.getContext();/*from   w w w .java 2s  . c o  m*/

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_host_list, container, false);
    ButterKnife.inject(this, root);

    // Get the host list
    // TODO: This is being done synchronously !!!
    final HostManager hostManager = HostManager.getInstance(context);
    ArrayList<HostInfo> hosts = hostManager.getHosts();
    HostInfo currentHost = hostManager.getHostInfo();
    int currentHostPosition = 0;
    for (int i = 0; i < hosts.size(); i++) {
        if ((currentHost != null) && (hosts.get(i).getId() == currentHost.getId())) {
            currentHostPosition = i;
        }
        hostInfoRows.add(new HostInfoRow(hosts.get(i), HostInfoRow.HOST_STATUS_CONNECTING));
    }

    // Setup the adapter
    hostGridView.setEmptyView(root.findViewById(android.R.id.empty));
    adapter = new HostListAdapter(context, R.layout.grid_item_host, hostInfoRows);
    hostGridView.setAdapter(adapter);
    hostGridView.setItemChecked(currentHostPosition, true);
    hostGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long itemId) {
            HostInfoRow clickedHostRow = hostInfoRows.get(position);

            // Set the clicked host active
            hostManager.switchHost(clickedHostRow.hostInfo);
            Intent intent = new Intent(context, RemoteActivity.class);
            context.startActivity(intent);

            //                switch (clickedHostRow.status) {
            //                    case HostInfoRow.HOST_STATUS_CONNECTING:
            //                        // Jsut switch the host
            //                        hostManager.switchHost(clickedHostRow.hostInfo);
            //                        break;
            //                    case HostInfoRow.HOST_STATUS_AVAILABLE:
            //                        // Set the clicked host active
            //                        hostManager.switchHost(clickedHostRow.hostInfo);
            //                        Intent intent = new Intent(context, RemoteActivity.class)
            //                                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            //                        context.startActivity(intent);
            //                        break;
            //                    case HostInfoRow.HOST_STATUS_UNAVAILABLE:
            //                        hostManager.switchHost(clickedHostRow.hostInfo);
            //                        // Check host status again
            //                        clickedHostRow.status = HostInfoRow.HOST_STATUS_CONNECTING;
            //                        adapter.notifyDataSetChanged();
            //                        updateHostStatus(clickedHostRow);
            //                        break;
            //                }
        }
    });

    return root;
}

From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java

private void showFirstStart() {
    stopRefreshAnimation();/* w w  w.  j av  a2s  . c o m*/
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    ViewGroup parent = (ViewGroup) ((ViewGroup) getActivity().findViewById(R.id.scrollview)).getChildAt(0);
    if (parent.findViewById(R.id.tracks_msg) == null)
        inflater.inflate(R.layout.no_tracks, parent);

    TypedValue typedValue = new TypedValue();
    getActivity().getTheme().resolveAttribute(R.attr.firstLaunchCoverDrawable, typedValue, true);
    int firstLaunchBGid = typedValue.resourceId;
    @SuppressWarnings("deprecation")
    BitmapDrawable bd = ((BitmapDrawable) getResources().getDrawable(firstLaunchBGid));

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());

    setCoverArt(bd != null ? bd.getBitmap() : null, null);
    ((TextSwitcher) getActivity().findViewById(R.id.switcher)).setText("");

    int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0"));
    if (themeNum > 0 && themeNum != 7) {
        TypedValue darkColorValue = new TypedValue();
        getActivity().getTheme().resolveAttribute(R.attr.colorPrimaryDark, darkColorValue, true);
        ((FadeInNetworkImageView) getActivity().findViewById(R.id.cover)).setColorFilter(darkColorValue.data,
                PorterDuff.Mode.OVERLAY);
    }

    getActivity().findViewById(R.id.error_msg).setVisibility(View.INVISIBLE);
    ((TextView) getActivity().findViewById(R.id.artist)).setText("");
    ((TextView) getActivity().findViewById(R.id.song)).setText("");
    getActivity().findViewById(R.id.top_gradient).setVisibility(View.INVISIBLE);
    getActivity().findViewById(R.id.bottom_gradient).setVisibility(View.INVISIBLE);
    getActivity().findViewById(R.id.edit_tags_btn).setVisibility(View.INVISIBLE);
}

From source file:com.saarang.samples.apps.iosched.ui.SessionsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(com.saarang.samples.apps.iosched.R.layout.fragment_sessions,
            container, false);/* ww  w.  j  ava  2  s. c  o  m*/
    mCollectionView = (CollectionView) root
            .findViewById(com.saarang.samples.apps.iosched.R.id.sessions_collection_view);
    mPreloader = new Preloader(ROWS_TO_PRELOAD);
    mCollectionView.setOnScrollListener(mPreloader);
    mEmptyView = (TextView) root.findViewById(com.saarang.samples.apps.iosched.R.id.empty_text);
    mLoadingView = root.findViewById(com.saarang.samples.apps.iosched.R.id.loading);
    return root;
}

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

private void setupContent(ViewGroup contentPanel) {
    mScrollView = (NestedScrollView) mWindow.findViewById(R.id.scrollView);
    mScrollView.setFocusable(false);//from  w  w w .j  a v a  2 s  .  co  m
    mScrollView.setNestedScrollingEnabled(false);

    // Special case for users that only want to display a String
    mMessageView = (TextView) contentPanel.findViewById(android.R.id.message);
    if (mMessageView == null) {
        return;
    }

    if (mMessage != null) {
        mMessageView.setText(mMessage);
    } else {
        mMessageView.setVisibility(View.GONE);
        mScrollView.removeView(mMessageView);

        if (mListView != null) {
            final ViewGroup scrollParent = (ViewGroup) mScrollView.getParent();
            final int childIndex = scrollParent.indexOfChild(mScrollView);
            scrollParent.removeViewAt(childIndex);
            scrollParent.addView(mListView, childIndex, new LayoutParams(MATCH_PARENT, MATCH_PARENT));
        } else {
            contentPanel.setVisibility(View.GONE);
        }
    }
}

From source file:org.andstatus.app.msg.TimelineActivity.java

private void updateAccountButtonText(ViewGroup mDrawerList) {
    TextView selectAccountButton = (TextView) mDrawerList.findViewById(R.id.selectAccountButton);
    String accountButtonText = buildAccountButtonText(mListParametersNew.myAccountUserId);
    selectAccountButton.setText(accountButtonText);
}

From source file:org.andstatus.app.msg.TimelineActivity.java

private void prepareCombinedTimelineToggle(ViewGroup list) {
    CheckBox combinedTimelineToggle = (CheckBox) list.findViewById(R.id.combinedTimelineToggle);
    combinedTimelineToggle.setChecked(isTimelineCombined());
    if (mListParametersNew.mSelectedUserId != 0
            && mListParametersNew.mSelectedUserId != mListParametersNew.myAccountUserId) {
        combinedTimelineToggle.setVisibility(View.GONE);
    } else {/*from  w w  w  .j  a va2 s.c  om*/
        // Show the "Combined" toggle even for one account to see messages, 
        // which are not on the timeline.
        // E.g. messages by users, downloaded on demand.
        combinedTimelineToggle.setVisibility(View.VISIBLE);
    }
}

From source file:com.activiti.android.ui.form.FormManager.java

/**
 * Works for 1.1 Form Definition//from w  w  w  .j  ava  2 s . co m
 *
 * @param li
 * @param isEdition
 */
protected void generateForm11(LayoutInflater li, boolean isEdition) {
    ViewGroup rootView = (ViewGroup) li.inflate(R.layout.form_root, null);
    ViewGroup hookView = rootView;
    fieldsIndex = new HashMap<>(data.getFields().size());

    boolean createGroup = true;

    ViewGroup groupRoot = null;
    BaseField field;
    for (FormFieldRepresentation fieldData : data.getFields()) {
        if (FormFieldTypes.GROUP.equals(fieldData.getType())) {
            if (groupRoot != null) {
                rootView.addView(groupRoot);
            }
            // Header
            field = generateField(fieldData, rootView, isEdition);
            createGroup = true;
            groupRoot = null;
        } else {
            if (createGroup) {
                // Create groupView
                groupRoot = (ViewGroup) li.inflate(R.layout.form_fields_group, null);
                hookView = (ViewGroup) groupRoot.findViewById(R.id.form_group_container);
                createGroup = false;
            }

            // Normal Field
            field = generateField(fieldData, hookView, isEdition);
        }

        fieldsOrderIndex.add(field);
        fieldsIndex.put(fieldData.getId(), field);

        // Mark All fields in edition mode
        if (isEdition) {
            // Mark required Field
            if (fieldData.isRequired()) {
                mandatoryFields.add(field);
            }

            if (fieldData instanceof RestFieldRepresentation) {
                field.setFragment(fr);
            }
        }

        // If requires fragment for pickers.
        if (field.isPickerRequired()) {
            field.setFragment(fr);
        }
    }

    // Now time to evaluate everyone
    evaluateViews();

    // Add Container to root ?
    if (groupRoot != null) {
        rootView.addView(groupRoot);
    }

    vRoot.addView(rootView);

    // OUTCOME
    if (!isEdition) {
        return;
    }
    View vr;
    if (data.getOutcomes() == null || data.getOutcomes().size() == 0) {
        outcomeIndex = new HashMap<>(1);
        vr = generateOutcome(rootView, getActivity().getString(R.string.form_default_outcome_complete), li);
        outcomeIndex.put(getActivity().getString(R.string.form_default_outcome_complete), vr);
    } else {
        outcomeIndex = new HashMap<>(data.getOutcomes().size());
        for (FormOutcomeRepresentation outcomeData : data.getOutcomes()) {
            vr = generateOutcome(rootView, outcomeData.getName(), li);
            outcomeIndex.put(outcomeData.getName(), vr);
        }
    }
}