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.mongolduu.android.ng.ChartFragment.java

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

    listview = (ListView) root.findViewById(R.id.list);

    listview.setOnItemClickListener(new OnItemClickListener() {
        @Override/*from w  ww.j  a  v a  2s  . c  om*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SongInfo songinfo = (SongInfo) parent.getAdapter().getItem(position);
            if (songinfo.isSavedOnDevice) {
                //Toast.makeText(SearchActivity.this, R.string.toast_message_already_downloaded, Toast.LENGTH_SHORT).show();
                playSong(songinfo);
            } else {
                downloadSong(songinfo);
            }
        }
    });
    listview.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            SongInfo songinfo = (SongInfo) listview.getAdapter()
                    .getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position);
            if (songinfo.isSavedOnDevice) {
                menu.add(fragmentIndex, R.id.context_menu_play_song, 0, R.string.context_menu_play_song);
                menu.add(fragmentIndex, R.id.context_menu_set_as_ringtone, 0,
                        R.string.context_menu_set_as_ringtone);
                menu.add(fragmentIndex, R.id.context_menu_remove_song_from_device, 0,
                        R.string.context_menu_remove_song_from_device);
            } else {
                menu.add(fragmentIndex, R.id.context_menu_download, 0, R.string.context_menu_download);
            }
        }
    });

    textandprogressbar = (ViewGroup) inflater.inflate(R.layout.text_and_progressbar, listview, false);
    listview.addFooterView(textandprogressbar, null, false);
    TextAndProgressBarUtils.initializeTextAndProgressBar(listview, textandprogressbar);
    TextAndProgressBarUtils.hideTextAndProgressBar(listview);

    listview.setAdapter(new SongInfoListAdapter(getActivity(), new LinkedList<SongInfo>(), true));

    fetchSongs(true);

    return root;
}

From source file:com.google.android.gms.location.sample.geofencing.LayoutChangesActivity.java

private void addMenuItemList() {
    // Instantiate a new "row" view.

    ArrayList<Geofence> geofenceList;
    if (LocationActivity.mGeofenceList == null) {
        geofenceList = populateGeofenceList();
    } else {/*from   ww w.  ja  va  2 s . co  m*/
        geofenceList = LocationActivity.mGeofenceList;
    }

    mContainerView.removeAllViews();
    if (geofenceList != null) {
        for (int i = 0; i < geofenceList.size(); i++) {
            final ViewGroup newView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.all_list_entries,
                    mContainerView, false);

            ((TextView) newView.findViewById(android.R.id.text1)).setText(geofenceList.get(i).getRequestId());

            itemNow = i;
            mContainerView.addView(newView, 0);

            newView.findViewById(R.id.edit_button).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Sample[] mSamples;
                    mSamples = new Sample[] { new Sample(R.string.action_edit_item, EditItemActivity.class), };

                    startActivity(new Intent(LayoutChangesActivity.this, mSamples[0].activityClass));

                }
            }

            );
        }
    }
}

From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPCompaniesFragment.java

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

    setHasOptionsMenu(true);/* w  w w .  j  av a  2s .co  m*/

    recyclerView = (ObservableRecyclerView) mView.findViewById(R.id.scroll);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setHasFixedSize(false);

    recyclerView.setAdapter(new CompaniesCellAdapter(getActivity()));

    Fragment parentFragment = getParentFragment();
    ViewGroup viewGroup = (ViewGroup) parentFragment.getView();
    if (viewGroup != null) {
        recyclerView.setTouchInterceptionViewGroup((ViewGroup) viewGroup.findViewById(R.id.container));
        if (parentFragment instanceof ObservableScrollViewCallbacks) {
            recyclerView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentFragment);
        }
    }

    final String searchText = ((MainActivity) getActivity()).getSearchString();
    final TextView notificationTextView = (TextView) mView.findViewById(R.id.companies_txt_notificationBox);

    if (searchText != null && !searchText.isEmpty()) {
        notificationTextView.setText(getResources().getString(R.string.notification_Search, searchText));
        notificationTextView.setVisibility(View.VISIBLE);
    } else {
        notificationTextView.setVisibility(View.GONE);
    }

    return mView;
}

From source file:com.pimp.calculator.fragments.CurrencyFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_currency, container, false);
    result_TV = (AutoResizeTextView) root.findViewById(R.id.curr_result_TV);
    resultant_TV = (AutoResizeTextView) root.findViewById(R.id.curr_resultant_TV);
    conversionRate = new ConversionRate();

    return root;/*from w ww . j  a  v  a2  s  .  c  om*/
}

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

    mRecyclerView.setAdapter(mAdapter);/* w  w w .  j av  a2  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);

    viewModel = ViewModelProviders.of(this, viewModelFactory).get(FacebookViewModel.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.getFacebookPosts().observe(this, facebookItems -> {
        if (facebookItems != null) {
            mEmptyView.setVisibility(View.GONE);
            if (!facebookItems.isEmpty()) {
                mAdapter.setData(facebookItems);
            } else {
                TextView t = (TextView) mEmptyView;
                t.setText("posts unavailable.");
                mEmptyView.setVisibility(View.VISIBLE);
            }
        }
    });

    viewModel.refresh();

    return root;
}

From source file:com.skubit.satoshidice.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    ViewGroup mActionBarLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.action_bar, null);
    TextView mTitle = (TextView) mActionBarLayout.findViewById(R.id.displayName);
    mTitle.setTypeface(FontManager.LITE);

    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setDisplayShowCustomEnabled(true);
    // getActionBar().setDisplayShowTitleEnabled(false);
    setColorResource(R.color.action_bar_coin_color);

    mAccountSettings = AccountSettings.get(this);
    String secret = mAccountSettings.retrieveSecret();
    if (TextUtils.isEmpty(secret)) {
        Intent intent = new Intent();
        intent.setClass(this, CreateAccountActivity.class);
        startActivity(intent);/*from www. ja v a 2 s.c  o  m*/
    }

    mAccountView = (DiceAccountView) findViewById(R.id.google_accounts);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {
        @Override
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            invalidateOptionsMenu();
        }
    };

    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    mDrawerListFrame = (LinearLayout) this.findViewById(R.id.left_drawer_frame);

    mDrawerAdapter = new DrawerAdapter(this, R.array.drawer_items);

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    mDrawerList.setAdapter(mDrawerAdapter);

    mCurrentPosition = AccountSettings.get(getBaseContext()).getCurrentIndex();

    mDrawerAdapter.setBoldPosition(mCurrentPosition);
    selectItem(mCurrentPosition);

    mAccountView.initialize(this, mDrawerLayout);
}

From source file:com.giovanniterlingen.windesheim.view.Fragments.ScheduleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_schedule, container, false);
    swipeRefreshLayout = viewGroup.findViewById(R.id.swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent, R.color.colorPrimaryText,
            R.color.colorPrimary);//from w  ww.j av a2  s .  c  om
    emptyTextView = viewGroup.findViewById(R.id.schedule_not_found);
    spinner = viewGroup.findViewById(R.id.progress_bar);
    recyclerView = viewGroup.findViewById(R.id.schedule_recyclerview);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    Lesson[] lessons = DatabaseController.getInstance().getLessons(yearMonthDayDateFormat.format(date));
    if (lessons.length > 0) {
        adapter = new ScheduleAdapter((ScheduleActivity) getActivity(), lessons,
                yearMonthDayDateFormat.format(date), date);
        recyclerView.setAdapter(adapter);
    } else {
        emptyTextView.setVisibility(View.VISIBLE);
    }
    return viewGroup;
}

From source file:gov.wa.wsdot.android.wsdot.ui.borderwait.BorderWaitSouthboundFragment.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 BorderWaitSouthboundFragment.BorderWaitAdapter(getActivity());
    mRecyclerView.setAdapter(mAdapter);//w  w  w  . j ava 2s.co 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 = (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);

    swipeRefreshLayout.setRefreshing(true);

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

    viewModel.init(BorderWaitViewModel.BorderDirection.SOUTHBOUND);

    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.getBorderWaits().observe(this, borderWaits -> {
        mBorderWaits.clear();
        mBorderWaits = borderWaits;
        mAdapter.notifyDataSetChanged();
    });

    mEmptyView = root.findViewById(R.id.empty_list_view);

    return root;
}

From source file:io.vit.vitio.StartScreens.LoginFragment.java

private void init(ViewGroup rootView) {
    regnoCol = (EditText) rootView.findViewById(R.id.regno_col);
    dateCol = (EditText) rootView.findViewById(R.id.date_col);
    monthCol = (EditText) rootView.findViewById(R.id.month_col);
    yearCol = (EditText) rootView.findViewById(R.id.year_col);
    phoneCol = (EditText) rootView.findViewById(R.id.phoneno_col);
    errorView = (TextView) rootView.findViewById(R.id.errortext);
    campusRadioGroup = (RadioGroup) rootView.findViewById(R.id.campus_select_radio_group);
    velloreRadio = (RadioButton) rootView.findViewById(R.id.vellore_radio);
    chennaiRadio = (RadioButton) rootView.findViewById(R.id.chennai_radio);
    signInbutton = (Button) rootView.findViewById(R.id.next_button);

    dataHandler = DataHandler.getInstance(getActivity());
    connectAPI = new ConnectAPI(getActivity());
    dialog = new ProgressDialog(getActivity());
}

From source file:com.rubengees.introduction.IntroductionFragment.java

@NonNull
private View initDefaultViews(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.introduction_fragment_default_content, container,
            false);/* www  .j  av a2  s . c o m*/
    TextView title = (TextView) root.findViewById(R.id.introduction_fragment_default_content_title);
    ImageView image = (ImageView) root.findViewById(R.id.introduction_fragment_default_content_image);
    ViewGroup descriptionContainer = (ViewGroup) root
            .findViewById(R.id.introduction_fragment_default_content_description_container);
    TextView description;

    if (slide.getTitle() != null) {
        title.setText(slide.getTitle());
        title.setMaxLines(getLineCountForTitle());
        title.setTypeface(IntroductionConfiguration.getInstance().getTitleTypeface());

        if (slide.getTitleSize() != null) {
            title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, slide.getTitleSize());
        }
    }

    if (slide.getDescription() == null && slide.getOption() != null) {
        AppCompatCheckBox option = (AppCompatCheckBox) inflater.inflate(R.layout.introduction_fragment_option,
                descriptionContainer, false);

        option.setText(slide.getOption().getTitle());
        option.setChecked(slide.getOption().isActivated());
        option.setMaxLines(getLineCountForDescription());
        option.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                slide.getOption().setActivated(isChecked);
            }
        });

        CompoundButtonCompat.setButtonTintList(option,
                ContextCompat.getColorStateList(getContext(), android.R.color.white));

        descriptionContainer.addView(option);
        description = option;
    } else {
        description = (TextView) inflater.inflate(R.layout.introduction_fragment_description,
                descriptionContainer, false);

        if (slide.getDescription() != null) {
            description.setText(slide.getDescription());
        }

        description.setMaxLines(getLineCountForDescription());
        descriptionContainer.addView(description);
    }

    description.setTypeface(IntroductionConfiguration.getInstance().getDescriptionTypeface());

    if (slide.getDescriptionSize() != null) {
        description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, slide.getDescriptionSize());
    }

    if (slide.getImageResource() != null) {
        image.setImageResource(slide.getImageResource());
    }

    IntroductionConfiguration.getInstance().callOnSlideInit(slide.getPosition(), title, image, description);

    return root;
}