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.jaspersoft.android.jaspermobile.dialog.NumberDialogFragment.java

@NonNull
@Override//from w  w  w  .ja  v  a2s.c  o  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
    ViewGroup customView = (ViewGroup) layoutInflater.inflate(R.layout.page_dialog_layout,
            (ViewGroup) getActivity().getWindow().getDecorView(), false);
    numberEditText = (EditText) customView.findViewById(R.id.customNumber);
    numberEditText.setFilters(new InputFilter[] { new InputFilterMinMax(1, mMaxValue) });

    if (mInitValue != Integer.MIN_VALUE) {
        numberEditText.setText("");
        numberEditText.append(String.valueOf(mInitValue));
    }

    builder.setTitle(mTitleRes);
    builder.setView(customView);
    builder.setNegativeButton(R.string.cancel, null);
    builder.setPositiveButton(R.string.ok, null);

    Dialog pageDialog = builder.create();
    pageDialog.setOnShowListener(this);
    return pageDialog;
}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

public void buildSurveyName(Survey survey, ViewGroup parent) {

    ViewGroup row = (ViewGroup) viewContext.getLayoutInflater().inflate(R.layout.survey_layout, parent);
    TextView name = (TextView) row.findViewById(R.id.surveyName);
    name.setText(survey.name);/*from w  w  w. j  a  v  a2s .co m*/
    name.setFocusableInTouchMode(true);
    name.setFocusable(true);
    TextView description = (TextView) row.findViewById(R.id.surveyDescription);
    description.setText(survey.description);

}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

public View buildLabel(Attribute attribute, ViewGroup parent) {
    ViewGroup view = (ViewGroup) viewContext.getLayoutInflater().inflate(R.layout.label_text_view, parent);
    TextView textView = (TextView) view.findViewById(R.id.fieldLabel);

    textView.setText(Utils.bold(attribute.description));
    return view;/*  w  w w .j ava 2 s  .  c  o  m*/
}

From source file:com.example.anandchandrasekar.wardrobeadvisor.FilterKindFragment.java

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

    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_filter_bar, container, false);
    //        TextView filterKindTextView = (TextView) rootView.findViewById(R.id.filterKindTextView);
    LinearLayout linearLayout = (LinearLayout) rootView.findViewById(R.id.hsv_ll);

    //        filterKindTextView.setText(filterKind);
    //        filterKindTextView.setRotation(-90);
    for (int i = 0; i < filtersList.size(); i++) {
        final ItemFilter currFilter = filtersList.get(i);
        final Integer filterId = currFilter.getId();

        View view = FilterView.createNew(getActivity(), currFilter);
        view.setOnClickListener(new View.OnClickListener() {
            @Override//from  w  w  w .j ava  2 s .  co  m
            public void onClick(View v) {
                if (selectedFiltersList.contains(currFilter)) {
                    removeFilter(currFilter);
                } else {
                    addFilter(currFilter);
                }
            }
        });

        filterViewMap.put(currFilter, view);
        linearLayout.addView(view);
    }

    updateSelectedFilters();

    return rootView;
}

From source file:es.ubiqua.atractivas.AppdiaPageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    AppTask.getDetalle(mPageNumber);//from ww w  .  j av a2 s. c  o  m
    if (appdia == null) {
        appdia = new HashMap<String, String>();
        appdia.put("id", "id");
        appdia.put("nombre", "nombre");
        appdia.put("thumbnail", "thumbnail");
        appdia.put("shortDescription", "shortDescription");
        appdia.put("image", "image");
        appdia.put("longDescription", "longDescription");
        appdia.put("urlclick", "urlclick");
    }

    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_appdia_page, container, false);

    FontLoader.overrideFonts(rootView, "bold");

    NoAutoScrollView scroll = (NoAutoScrollView) rootView.findViewById(R.id.content);

    if (((AppdiaActivity) getActivity()).m_parts.size() <= 1) {
        ((AppdiaActivity) getActivity()).hideButtons();
    } else {
        scroll.setOnEndScrollListener(new NoAutoScrollView.OnEndScrollListener() {
            @Override
            public void onEndScroll(boolean home, boolean end) {
                if (home || end) {
                    ((AppdiaActivity) getActivity()).showButtons();
                } else {
                    ((AppdiaActivity) getActivity()).hideButtons();
                }
            }
        });
    }

    // Set the title view to show the page number.
    ((TextView) rootView.findViewById(R.id.DetalleCategoria)).setText("App recomendada");
    ((TextView) rootView.findViewById(R.id.DetalleTitulo)).setText(appdia.get("nombre"));

    // whenever you want to load an image from url
    // call DisplayImage function
    // url - image url to load
    // loader - loader image, will be displayed before getting image
    // image - ImageView

    imgLoader.DisplayImage(appdia.get("image"), R.drawable.placeholder_detalle,
            (ImageView) rootView.findViewById(R.id.DetalleImagen));

    ((WebView) rootView.findViewById(R.id.DestalleFulltext))
            .loadData(HEADER + appdia.get("longDescription") + FOOTER, "text/html; charset=UTF-8", null);

    return rootView;
}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

private Spinner buildSpinner(Attribute attribute, ViewGroup parent) {

    ViewGroup row = (ViewGroup) viewContext.getLayoutInflater().inflate(R.layout.input_spinner_view, parent);

    Spinner spinner = (Spinner) row.findViewById(R.id.spinner);
    spinner.setPrompt("Select " + attribute.description);
    ArrayList<AttributeOption> options = new ArrayList<Attribute.AttributeOption>(attribute.options.length + 1);
    options.addAll(Arrays.asList(attribute.options));

    ArrayAdapter<AttributeOption> adapter = new ArrayAdapter<AttributeOption>(viewContext,
            R.layout.multiline_spinner_item, options);
    adapter.setDropDownViewResource(R.layout.multiline_spinner_dropdown_item);
    spinner.setAdapter(adapter);/*  w w  w.  j a v a  2  s.  c  o m*/

    return spinner;
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionFeedbackFragment.java

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

    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_session_feedback, null);

    mTitle = (TextView) rootView.findViewById(R.id.session_title);

    mSessionRatingFeedbackBar = RatingBarHelper.create(rootView.findViewById(R.id.session_rating_container));
    mQ1FeedbackBar = RatingBarHelper.create(rootView.findViewById(R.id.session_feedback_q1_container));
    mQ2FeedbackBar = RatingBarHelper.create(rootView.findViewById(R.id.session_feedback_q2_container));
    mQ3FeedbackBar = RatingBarHelper.create(rootView.findViewById(R.id.session_feedback_q3_container));

    mQ4RadioGroup = (RadioGroup) rootView.findViewById(R.id.session_feedback_q4);

    mComments = (EditText) rootView.findViewById(R.id.session_feedback_comments);

    if (mVariableHeightHeader) {
        View headerView = rootView.findViewById(R.id.header_session);
        ViewGroup.LayoutParams layoutParams = headerView.getLayoutParams();
        layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        headerView.setLayoutParams(layoutParams);
    }/*  w w w .ja va 2  s  . c o  m*/

    rootView.findViewById(R.id.submit_feedback_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            submitAllFeedback();
            EasyTracker.getTracker().sendEvent("Session", "Feedback", mTitleString, 0L);
            LOGD("Tracker", "Feedback: " + mTitleString);
            getActivity().finish();
        }
    });
    return rootView;
}

From source file:net.naonedbus.card.Card.java

public View getView(final ViewGroup container) {
    final LayoutInflater inflater = LayoutInflater.from(mContext);

    final ViewGroup base = (ViewGroup) inflater.inflate(R.layout.card_base, container, false);
    final View view = inflater.inflate(mLayoutId, base, false);

    final TextView title = (TextView) base.findViewById(android.R.id.title);
    setTypefaceRobotoLight(title);/* w ww  .ja va2  s  .c om*/
    title.setText(mTitleId);

    mProgress = base.findViewById(android.R.id.progress);
    mMessage = (TextView) base.findViewById(android.R.id.message);
    mMoreActionView = (TextView) base.findViewById(android.R.id.button1);
    mContent = (ViewGroup) base.findViewById(android.R.id.content);
    mContent.addView(view);

    bindView(container.getContext(), base, view);

    return base;
}

From source file:gov.wa.wsdot.android.wsdot.ui.mountainpasses.MountainPassesFragment.java

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

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

    mRecyclerView = root.findViewById(R.id.my_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);

    mAdapter = new MountainPassAdapter(getActivity());
    mRecyclerView.setAdapter(mAdapter);//from  w w w. java  2  s.  c o m

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity()));

    // 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(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    swipeRefreshLayout = root.findViewById(R.id.swipe_container);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light,
            R.color.holo_orange_light, R.color.holo_red_light);

    mEmptyView = root.findViewById(R.id.empty_list_view);
    mEmptyView.setVisibility(View.GONE);

    viewModel = ViewModelProviders.of(this, viewModelFactory).get(MountainPassViewModel.class);

    viewModel.getResourceStatus().observe(this, resourceStatus -> {
        if (resourceStatus != null) {
            switch (resourceStatus.status) {
            case LOADING:
                swipeRefreshLayout.setRefreshing(true);
                break;
            case SUCCESS:
                swipeRefreshLayout.setRefreshing(false);
                break;
            case ERROR:
                swipeRefreshLayout.setRefreshing(false);
                Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_LONG).show();
            }
        }
    });

    viewModel.getPasses().observe(this, passes -> {
        mAdapter.setData(passes);
    });

    return root;
}

From source file:net.soulwolf.widget.parallaxrefresh.ParallaxScrollLayout.java

private void ensurePlaceholderView() {
    if (mParallaxTarget != null && mPlaceholderView == null) {
        // To avoid repetition and add PlaceholderView
        ViewGroup targetView = (ViewGroup) mParallaxTarget;
        View view = targetView.findViewById(R.id.psvPlaceholderView);
        if (view != null) {
            targetView.removeView(view);
        }/*  w  w w .j  a v  a  2  s  .c  o  m*/
        int width = mParallaxHolder.getRealWidth();
        int height = getOriginalHeight();
        ViewGroup.LayoutParams params = generatePlaceholderLayoutParams(mParallaxTarget, width, height);
        // Due to system {@link android.widget.Space} minimum compatible to API 14,
        // the library minimum support API 9, so rewrite the View
        mPlaceholderView = new PlaceholderView(getContext());
        mPlaceholderView.setLayoutParams(params);
        mPlaceholderView.setId(R.id.psvPlaceholderView);
        ParallaxScrollObserver observer = (ParallaxScrollObserver) mParallaxTarget;
        observer.setPlaceholder(mPlaceholderView);
        observer.setScrollCallback(this);
    }
}