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.luorrak.ouroboros.deepzoom.DeepZoomFragment.java

@Nullable
@Override//from w  w w .j ava  2  s .  co m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_deepzoom, container, false);
    setHasOptionsMenu(true);
    final LinearLayout deepzoomContainer = (LinearLayout) rootView.findViewById(R.id.deepzoom_container);
    photoView = (PhotoView) rootView.findViewById(R.id.deepzoom_photoview);
    photoView.setMaximumScale(24);
    mediaPlayButton = (ImageView) rootView.findViewById(R.id.deepzoom_media_play_button);
    mediaPlayButton.setVisibility(View.GONE);

    progressBar = (ProgressBar) rootView.findViewById(R.id.progress_bar);
    progressBar.setVisibility(View.VISIBLE);

    Ion.with(photoView).load(ChanUrls.getThumbnailUrl(boardName, mediaItem.fileName)).withBitmapInfo()
            .setCallback(new FutureCallback<ImageViewBitmapInfo>() {
                @Override
                public void onCompleted(Exception e, ImageViewBitmapInfo result) {
                    if (e != null) {
                        return;
                    }
                    progressBar.setVisibility(View.INVISIBLE);
                    if (result.getException() == null) {
                        Util.setSwatch(deepzoomContainer, result);
                    }

                    if (mediaItem.ext.equals(".webm") || mediaItem.ext.equals(".mp4")) {
                        return;
                    }

                    Ion.with(photoView).crossfade(true).deepZoom()
                            .load(ChanUrls.getImageUrl(boardName, mediaItem.fileName, mediaItem.ext))
                            .withBitmapInfo();
                }
            });
    return rootView;
}

From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.expresslanes.SeattleExpressLanesFragment.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 ItemAdapter(null);

    mRecyclerView.setAdapter(mAdapter);//from  w  w w .  j a  v  a2s .c om

    mRecyclerView.addItemDecoration(new DividerNoBottom(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);

    routeImage.put(5, R.drawable.ic_list_i5);
    routeImage.put(90, R.drawable.ic_list_i90);

    viewModel = ViewModelProviders.of(this, viewModelFactory).get(ExpressLanesViewModel.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);
                TextView t = (TextView) mEmptyView;
                t.setText(R.string.no_connection);
                mEmptyView.setVisibility(View.VISIBLE);
                Toast.makeText(getContext(), "connection error", Toast.LENGTH_SHORT).show();
            }
        }
    });

    viewModel.getExpressLanesStatus().observe(this, expressLaneItems -> {
        if (expressLaneItems != null) {
            mEmptyView.setVisibility(View.GONE);
            mAdapter.setData(expressLaneItems);
        }
    });

    viewModel.refresh();

    return root;
}

From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.socialmedia.youtube.YouTubeFragment.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 VideoItemAdapter(null);

    mRecyclerView.setAdapter(mAdapter);/*from  ww w  .  j  av  a  2  s  .c o  m*/

    // 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);

    viewModel = ViewModelProviders.of(this, viewModelFactory).get(YouTubeViewModel.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);
                TextView t = (TextView) mEmptyView;
                t.setText(R.string.no_connection);
                mEmptyView.setVisibility(View.VISIBLE);
                Toast.makeText(getContext(), "connection error", Toast.LENGTH_SHORT).show();
            }
        }
    });

    viewModel.getYouTubePosts().observe(this, youTubeItems -> {
        if (youTubeItems != null) {
            mEmptyView.setVisibility(View.GONE);
            if (!youTubeItems.isEmpty()) {
                mAdapter.setData(youTubeItems);
            } else {
                TextView t = (TextView) mEmptyView;
                t.setText("posts unavailable.");
                mEmptyView.setVisibility(View.VISIBLE);
            }
        }
    });

    viewModel.refresh();

    return root;
}

From source file:com.lvstudio.wallpapers.naturalwallpapers.ScreenSlidePageFragment.java

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

    //        mPageNumber = getArguments().getInt(ARG_PAGE);
    //        lstPhoto = getArguments().getStringArrayList("listPhoto");
    //        listPhotoURL = getArguments().getStringArrayList("listPhotoURL");
    //        options = new DisplayImageOptions.Builder().cacheInMemory(false).cacheOnDisk(true).showImageOnFail(R.drawable.load_fail).imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.ARGB_8888).build();

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

    imgPhoto = (ImageView) rootView.findViewById(R.id.imgPhoto);
    imgAvatar = (ImageView) rootView.findViewById(R.id.imgAvatar);

    txtDecription = (TextView) rootView.findViewById(R.id.txtDescription);
    txtLicense = (TextView) rootView.findViewById(R.id.txtLicense);
    txtOwnerName = (TextView) rootView.findViewById(R.id.txtOwnerName);
    txtOwnerUrl = (TextView) rootView.findViewById(R.id.txtOwnerUrl);
    txtLocation = (TextView) rootView.findViewById(R.id.txtLocation);
    imgFavorite = (ImageView) rootView.findViewById(R.id.imgFavorite);
    imgExpander = (ImageView) rootView.findViewById(R.id.imgExpander);
    imgPhoto.setOnClickListener(new OnClickListener() {

        @Override//from   w w  w  .j  a va 2 s  .co  m
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), PhotoZoomActivity.class);
            intent.putExtra("URL", listPhotoURL.get(mPageNumber));
            startActivity(intent);
        }
    });

    if (photo == null) {
        new LoadDataDobackground(lstPhoto.get(mPageNumber)).execute();
    } else {
        imageLoader.displayImage(listPhotoURL.get(mPageNumber), imgPhoto, options);

        imageLoader.displayImage(photo.getAvatarPath(), imgAvatar, options);

        //txtTitle.setText(photo.title);
        txtDecription.setText(Html.fromHtml(photo.description));
        txtLicense.setText(photo.getLicense());
        txtOwnerName.setText(photo.getOwnerName());
        txtOwnerUrl.setText(photo.url);
        txtLocation.setText(photo.getLocation());

        isFavorite = checkFavorite();
        if (isFavorite) {
            imgFavorite.setVisibility(View.VISIBLE);
        } else {
            imgFavorite.setVisibility(View.GONE);
        }

    }

    imgAvatar.setVisibility(View.VISIBLE);

    txtDecription.setVisibility(View.GONE);
    txtLocation.setVisibility(View.GONE);
    imgExpander.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (txtDecription.getVisibility() == View.GONE) {
                txtDecription.setVisibility(View.VISIBLE);
                txtLocation.setVisibility(View.VISIBLE);
                imgExpander.setImageResource(R.drawable.ic_find_previous_holo_dark);
            } else {
                txtDecription.setVisibility(View.GONE);
                txtLocation.setVisibility(View.GONE);
                imgExpander.setImageResource(R.drawable.ic_find_next_holo_dark);
            }
        }
    });

    //txtTitle.setTypeface(StaticFunction.getTypeface(getActivity()));
    //txtLicense.setTypeface(StaticFunction.getTypeface(getActivity()));

    return rootView;
}

From source file:com.egoclean.testpregnancy.util.ActivityHelper.java

/**
 * Sets the action bar title to the given string.
 *//*from   w  w w  . jav a 2 s.  co  m*/
public void setActionBarTitle(CharSequence title) {
    ViewGroup actionBar = getActionBarCompat();
    if (actionBar == null) {
        return;
    }

    TextView titleText = (TextView) actionBar.findViewById(R.id.actionbar_compat_text);
    if (titleText != null) {
        titleText.setText(title);
    }
}

From source file:com.binoy.vibhinna.VibhinnaFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterView.AdapterContextMenuInfo info;
    PropManager propmanager = new PropManager(getActivity().getApplicationContext());
    try {//from  w  w w. j  a v a2s  .c o  m
        // Casts the incoming data object into the type for AdapterView
        // objects.
        info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        // If the menu object can't be cast, logs an error.
        Log.w("Exception", "exception in getting menuinfo");
        return;
    }
    Cursor cursor = (Cursor) getListAdapter().getItem(info.position);
    String s1 = Constants.SD_PATH + propmanager.mbActivePath();
    String s2 = cursor.getString(7);
    if (cursor.equals(null) || s1.equals(s2))
        return;
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
        LayoutInflater headerInflater = (LayoutInflater) getSherlockActivity()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        ViewGroup header = (ViewGroup) headerInflater.inflate(R.layout.context_menu_header, null);
        TextView title = (TextView) header.findViewById(R.id.context_menu_title);
        title.setText(cursor.getString(1));
        menu.setHeaderView(header);
    } else
        menu.setHeaderTitle(cursor.getString(1));
    android.view.MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.context_menu, menu);
}

From source file:com.andrew.apollo.ui.fragments.ThemeFragment.java

/**
 * {@inheritDoc}/*from  w ww  .  j a  v a  2  s . c o  m*/
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    // The View for the fragment's UI
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.grid_base, null);
    // Initialize the grid
    mGridView = (GridView) rootView.findViewById(R.id.grid_base);
    // Release any reference to the recycled Views
    mGridView.setRecyclerListener(new RecycleHolder());
    // Set the new theme
    mGridView.setOnItemClickListener(this);
    // Listen for ContextMenus to be created
    mGridView.setOnCreateContextMenuListener(this);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        // Limit the columns to one in portrait mode
        mGridView.setNumColumns(1);
    } else {
        // And two for landscape
        mGridView.setNumColumns(2);
    }
    return rootView;
}

From source file:com.emotion.emotioncontrol.fragments.NavigationDrawerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
    mDrawerListView = (ListView) root.findViewById(R.id.list);
    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override/*from  ww  w.j  a  v a 2s  .  c o m*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectItem(position);
        }
    });
    mDrawerListView.setAdapter(new NavigationDrawerAdapter(getActionBar().getThemedContext(),
            getResources().getStringArray(R.array.navigation_drawer_entries), R.array.navigation_drawer_icons));
    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
    return root;
}

From source file:com.eugene.fithealthmaingit.UI.Adapters.ChooseAddMealPagerAdapter.ChooseAddMealPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup viewGroup, int position) {
    int resId = 0;
    switch (position) {
    case 0://from  w ww.  j  av a2 s  . c o  m
        resId = R.id.manual;
        break;
    case 1:
        resId = R.id.favorites;
        break;
    case 2:
        resId = R.id.recipes;
        break;
    case 3:
        resId = R.id.recent;
        break;
    }
    return viewGroup.findViewById(resId);
}

From source file:com.andrew.apollo.ui.fragments.profile.AlbumSongFragment.java

/**
 * {@inheritDoc}//from   ww  w  .  ja v  a 2 s. c o m
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    // The View for the fragment's UI
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.list_base, null);
    // Initialize the list
    mListView = (ListView) rootView.findViewById(R.id.list_base);
    // Set the data behind the list
    mListView.setAdapter(mAdapter);
    // Release any references to the recycled Views
    mListView.setRecyclerListener(new RecycleHolder());
    // Listen for ContextMenus to be created
    mListView.setOnCreateContextMenuListener(this);
    // Play the selected song
    mListView.setOnItemClickListener(this);
    // To help make scrolling smooth
    mListView.setOnScrollListener(new VerticalScrollListener(null, mProfileTabCarousel, 0));
    // Remove the scrollbars and padding for the fast scroll
    mListView.setVerticalScrollBarEnabled(false);
    mListView.setFastScrollEnabled(false);
    mListView.setPadding(0, 0, 0, 0);
    return rootView;
}