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:nu.yona.app.ui.dashboard.CustomPageAdapter.java

private ViewGroup initiateWeekActivityReport(ViewGroup collection, int position) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.detail_activity_fragment, collection, false);
    WeekActivity weekActivity = weekActivities.get(position);
    View spreadView = layout.findViewById(R.id.spreadGraphView);
    goalDesc = (YonaFontTextView) spreadView.findViewById(R.id.goalDesc);
    goalType = (YonaFontTextView) spreadView.findViewById(R.id.goalType);
    goalScore = (YonaFontTextView) spreadView.findViewById(R.id.goalScore);
    mSpreadGraph = (SpreadGraph) spreadView.findViewById(R.id.spreadGraph);
    if (isWeekControlVisible) {
        ViewGroup weekChart = (ViewGroup) layout.findViewById(R.id.week_chart);
        weekChart.setVisibility(View.VISIBLE); // week control
        showWeekChartData(weekChart, weekActivity);
    }//from   w w w.  jav a  2 s  .c  o  m
    if (weekActivity != null && weekActivity.getLinks() != null
            && (weekActivity.getLinks().getReplyComment() != null
                    || weekActivity.getLinks().getAddComment() != null)) {
        YonaApplication.getEventChangeManager().notifyChange(EventChangeManager.EVENT_SHOW_CHAT_OPTION, null);
    }
    graphView = ((FrameLayout) layout.findViewById(R.id.graphView));
    GoalsEnum goalsEnum;
    goalsEnum = GoalsEnum.fromName(weekActivity.getYonaGoal().getType());
    if (goalsEnum == GoalsEnum.BUDGET_GOAL && weekActivity.getYonaGoal().getMaxDurationMinutes() == 0) {
        goalsEnum = GoalsEnum.NOGO;
    }
    graphView.addView(inflateActivityView(inflater, goalsEnum, layout));
    updateView(new ChartItemHolder(graphView, null, goalsEnum), weekActivity, null);
    collection.addView(layout);
    return layout;
}

From source file:com.conferenceengineer.android.iosched.ui.ScheduleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_empty_container, container,
            false);/*  w  w w  .jav a2 s  . c om*/
    inflater.inflate(R.layout.empty_waiting_for_sync, (ViewGroup) root.findViewById(android.R.id.empty), true);
    root.setBackgroundColor(Color.WHITE);
    ListView listView = (ListView) root.findViewById(android.R.id.list);
    listView.setItemsCanFocus(true);
    listView.setCacheColorHint(Color.WHITE);
    listView.setSelector(android.R.color.transparent);

    return root;
}

From source file:com.ushahidi.android.app.ui.tablet.ListReportFragment.java

protected View headerView() {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.list_report_header, getListView(), false);
    TextView textView = (TextView) viewGroup.findViewById(R.id.filter_report);
    textView.addTextChangedListener(new TextWatcher() {

        public void afterTextChanged(Editable arg0) {

        }//from  w  w  w .  j a  v a  2s  .  c  o m

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {

            if (!(TextUtils.isEmpty(s.toString()))) {
                filterTitle = s;
                mHandler.post(filterReportList);
            }

        }

    });
    return viewGroup;
}

From source file:com.cryart.sabbathschool.adapter.SSReadingViewAdapter.java

@Override
public Object instantiateItem(ViewGroup collection, int position) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.ss_reading_view, collection, false);
    collection.addView(layout);//w w  w  .j  a v  a 2 s . co  m

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.mContext);
    SSReadingDisplayOptions ssReadingDisplayOptions = new SSReadingDisplayOptions(
            prefs.getString(SSConstants.SS_SETTINGS_THEME_KEY, SSReadingDisplayOptions.SS_THEME_LIGHT),
            prefs.getString(SSConstants.SS_SETTINGS_SIZE_KEY, SSReadingDisplayOptions.SS_SIZE_MEDIUM),
            prefs.getString(SSConstants.SS_SETTINGS_FONT_KEY, SSReadingDisplayOptions.SS_FONT_LATO));

    final SSReadingView ssReadingView = layout.findViewById(R.id.ss_reading_view);
    ssReadingView.setReadingDisplayOptions(ssReadingDisplayOptions);
    ssReadingView.setContextMenuCallback(ssReadingViewModel);
    ssReadingView.setHighlightsCommentsCallback(ssReadingViewModel);
    ssReadingView.setReadHighlights(ssReadHighlights.get(position));
    ssReadingView.setReadComments(ssReadComments.get(position));
    ssReadingView.loadRead(ssReads.get(position));

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            if (ssReadingView != null) {
                ssReadingView.updateHighlights();
                ssReadingView.updateComments();
            }
        }
    }, 800);

    layout.setTag("ssReadingView_" + position);

    return layout;
}

From source file:com.by_syk.lib.nanoiconpack.dialog.QrcodeDialog.java

@NonNull
@Override/*ww w  . ja  va2  s. co  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ViewGroup viewGroup = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.dialog_qrcode, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).setView(viewGroup);

    Bundle bundle = getArguments();
    if (bundle != null) {
        String title = bundle.getString("title");
        String qrcodeUrl = bundle.getString("qrcodeUrl");
        if (!TextUtils.isEmpty(title)) {
            builder.setTitle(title);
        }
        if (!TextUtils.isEmpty(qrcodeUrl)) {
            int qrcodeSize = getResources().getDimensionPixelSize(R.dimen.qrcode_size);
            QRCode qrCode = QRCode.from(qrcodeUrl).withSize(qrcodeSize, qrcodeSize);
            ((ImageView) viewGroup.findViewById(R.id.iv_qrcode)).setImageBitmap(qrCode.bitmap());
        }
    }

    return builder.create();
}

From source file:com.adithya321.sharesanalysis.fragments.FundFlowFragment.java

@Nullable
@Override/*w w  w .ja v a 2 s . c om*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_fund_flow, container, false);

    Window window = getActivity().getWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
    ((AppCompatActivity) getActivity()).getSupportActionBar()
            .setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));

    databaseHandler = new DatabaseHandler(getContext());
    fundIn = (TextView) root.findViewById(R.id.fund_in);
    fundOut = (TextView) root.findViewById(R.id.fund_out);
    fundsListView = (ListView) root.findViewById(R.id.funds_list_view);
    setViews();

    FloatingActionButton addFundFab = (FloatingActionButton) root.findViewById(R.id.add_fund_fab);
    addFundFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Add Fund Flow");
            dialog.setContentView(R.layout.dialog_add_fund);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            Calendar calendar = Calendar.getInstance();
            year_start = calendar.get(Calendar.YEAR);
            month_start = calendar.get(Calendar.MONTH) + 1;
            day_start = calendar.get(Calendar.DAY_OF_MONTH);
            final Button selectDate = (Button) dialog.findViewById(R.id.select_date);
            selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/")
                    .append(year_start));
            selectDate.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start,
                            month_start - 1, day_start);
                    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            selectDate.setText(new StringBuilder().append(day_start).append("/")
                                    .append(month_start).append("/").append(year_start));
                        }
                    });
                    dialog.show();
                }
            });

            final EditText amount = (EditText) dialog.findViewById(R.id.amount);
            Button addFundBtn = (Button) dialog.findViewById(R.id.add_fund_btn);
            addFundBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Fund fund = new Fund();
                    fund.setId(databaseHandler.getNextKey("fund"));

                    String stringStartDate = year_start + " " + month_start + " " + day_start;
                    DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH);
                    try {
                        Date date = format.parse(stringStartDate);
                        fund.setDate(date);
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    try {
                        fund.setAmount(Double.parseDouble(amount.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Amount", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    if (((RadioButton) dialog.findViewById(R.id.radioBtn_fund_in)).isChecked())
                        fund.setType("in");
                    else if (((RadioButton) dialog.findViewById(R.id.radioBtn_fund_out)).isChecked())
                        fund.setType("out");
                    else {
                        Toast.makeText(getActivity(), "Invalid Fund Type", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    databaseHandler.addFund(fund);
                    setViews();
                    dialog.dismiss();
                }
            });
        }
    });

    return root;
}

From source file:io.intue.kamu.BestNearbyFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_sessions, container, false);
    mCollectionView = (CollectionView) root.findViewById(R.id.sessions_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;/*w w w .j a  v  a2s  .  c  om*/
}

From source file:io.vit.vitio.Fragments.SubjectView.SubjectViewFragmentTrial.java

private void init(ViewGroup rootView) {

    //Get Arguments
    try {/* ww w  . j  a va 2s. c  o m*/
        MY_CLASS_NUMBER = getArguments().getString("class_number");
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(getActivity(), "Error", Toast.LENGTH_SHORT).show();
        getActivity().finish();
    }
    //Initialize TextViews
    subName = (TextView) rootView.findViewById(R.id.subject_name);
    subType = (TextView) rootView.findViewById(R.id.subject_type);
    subCode = (TextView) rootView.findViewById(R.id.subject_code);
    subSlot = (TextView) rootView.findViewById(R.id.subject_slot);
    subVenue = (TextView) rootView.findViewById(R.id.subject_venue);
    subPer = (TextView) rootView.findViewById(R.id.subject_perc);
    subFaculty = (TextView) rootView.findViewById(R.id.subject_faculty);
    //subSchool = (TextView) rootView.findViewById(R.id.subject_school);
    attended = (TextView) rootView.findViewById(R.id.subject_att_out_total);
    attendClassText = (TextView) rootView.findViewById(R.id.attend_class_text);
    missClassText = (TextView) rootView.findViewById(R.id.miss_class_text);

    //Initialize ImageViews
    subColorCircle = (ImageView) rootView.findViewById(R.id.subject_color_circle);
    missMinus = (LinearLayout) rootView.findViewById(R.id.miss_minus);
    missAdd = (LinearLayout) rootView.findViewById(R.id.miss_plus);
    attendMinus = (LinearLayout) rootView.findViewById(R.id.attend_minus);
    attendAdd = (LinearLayout) rootView.findViewById(R.id.attend_plus);
    fullViewTint = (LinearLayout) rootView.findViewById(R.id.full_view_tint);
    back_button = (ImageView) rootView.findViewById(R.id.back_button);
    schoolImage = (ImageView) rootView.findViewById(R.id.school_image);

    //Initialize LinearLayouts
    attBar = (LinearLayout) rootView.findViewById(R.id.subject_per_bar);

    //Initialize Others
    recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view);
    attFab = (FloatingActionButton) rootView.findViewById(R.id.att_fab);
    marksFab = (FloatingActionButton) rootView.findViewById(R.id.marks_fab);
    //reminderFab = (FloatingActionButton) rootView.findViewById(R.id.reminder_fab);
    floatingMenu = (FloatingActionsMenu) rootView.findViewById(R.id.left_labels);
    dataHandler = DataHandler.getInstance(getActivity());
    toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    collapsingToolbarLayout = (CollapsingToolbarLayout) rootView.findViewById(R.id.collapsing_toolbar);
    nestedScrollView = (NestedScrollView) rootView.findViewById(R.id.scrollview);
    theme = new MyTheme(getActivity());
    parseTimeTable = new ParseTimeTable(dataHandler.getCoursesList(), dataHandler);
}

From source file:gov.wa.wsdot.android.wsdot.ui.camera.CameraImageFragment.java

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

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

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

    mImage = mRootView.findViewById(R.id.image);

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

    viewModel.getResourceStatus().observe(this, resourceStatus -> {
        if (resourceStatus != null) {
            switch (resourceStatus.status) {
            case LOADING:
                mSwipeRefreshLayout.setRefreshing(true);
                break;
            case SUCCESS:
                mSwipeRefreshLayout.setRefreshing(false);
                break;
            case ERROR:
                mSwipeRefreshLayout.setRefreshing(false);
                Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_LONG).show();
            }// ww w .  j  a  v  a  2  s .c om
        }
    });

    viewModel.getCamera(mId).observe(this, camera -> {
        if (camera != null) {
            mTitle = camera.getTitle();
            mUrl = camera.getUrl();
            mIsStarred = camera.getIsStarred() != 0;
            getLoaderManager().initLoader(0, null, this);

            if (camera.getMilepost() != null) {
                ((TextView) mRootView.findViewById(R.id.milepost))
                        .setText(String.format("milepost %s", camera.getMilepost()));
            }

            if (!camera.getDirection().equals("null")) {
                String directionString;
                switch (camera.getDirection()) {
                case "N":
                    directionString = "This camera faces north";
                    break;
                case "S":
                    directionString = "This camera faces south";
                    break;
                case "E":
                    directionString = "This camera faces east";
                    break;
                case "W":
                    directionString = "This camera faces west";
                    break;
                default:
                    directionString = "This camera could be pointing in a number of directions for operational reasons.";
                    break;
                }
                mRootView.findViewById(R.id.direction).setVisibility(View.VISIBLE);
                ((TextView) mRootView.findViewById(R.id.direction)).setText(directionString);
            } else {
                mRootView.findViewById(R.id.direction).setVisibility(View.GONE);
            }
        }
    });

    return mRootView;
}

From source file:gov.wa.wsdot.android.wsdot.ui.BlogFragment.java

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

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

    // 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.setColorScheme(17170451, // android.R.color.holo_blue_bright 
            17170452, // android.R.color.holo_green_light 
            17170456, // android.R.color.holo_orange_light 
            17170454); // android.R.color.holo_red_light)

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

    return root;//from  w w  w . j  a v  a2s .  c  o m
}