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:cx.ring.fragments.AccountCreationFragment.java

private AlertDialog showImportDialog() {
    Activity ownerActivity = getActivity();

    AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity);
    LayoutInflater inflater = ownerActivity.getLayoutInflater();
    ViewGroup v = (ViewGroup) inflater.inflate(R.layout.dialog_account_import, null);
    final TextView pwd = (TextView) v.findViewById(R.id.pwd_txt);
    builder.setMessage(R.string.account_import_message).setTitle(R.string.account_import_account)
            .setPositiveButton(R.string.account_import_account, new DialogInterface.OnClickListener() {
                @Override//ww w . j a v a2 s  .c o  m
                public void onClick(DialogInterface dialog, int which) {
                    if (!TextUtils.isEmpty(mDataPath)) {
                        new ImportAccountTask().execute(mDataPath, pwd.getText().toString());
                    }
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    /* Terminate with no action */
                }
            }).setView(v);

    final AlertDialog alertDialog = builder.create();
    alertDialog.show();
    return alertDialog;
}

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

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

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_spinner, 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));

    // Since we are building a simple navigation, just hide the spinner.
    mLoadingSpinner = root.findViewById(R.id.loading_spinner);
    mLoadingSpinner.setVisibility(View.GONE);

    return root;// w w  w. j a v  a 2  s .  co  m
}

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

@Nullable
@Override//from w  ww . j av a 2  s . com
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_purchase, container, false);

    databaseHandler = new DatabaseHandler(getContext());
    sharePurchasesRecyclerView = (RecyclerView) root.findViewById(R.id.share_purchases_recycler_view);
    emptyTV = (TextView) root.findViewById(R.id.empty);
    arrow = (ImageView) root.findViewById(R.id.arrow);
    setRecyclerViewAdapter();

    FloatingActionButton addPurchaseFab = (FloatingActionButton) root.findViewById(R.id.add_purchase_fab);
    addPurchaseFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Add Share Purchase");
            dialog.setContentView(R.layout.dialog_add_share_purchase);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            final AutoCompleteTextView name = (AutoCompleteTextView) dialog.findViewById(R.id.share_name);
            List<String> nseList = ShareUtils.getNseList(getContext());
            ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(getContext(),
                    android.R.layout.simple_dropdown_item_1line, nseList);
            name.setAdapter(arrayAdapter);

            final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner);
            ArrayList<String> shares = new ArrayList<>();
            for (Share share : sharesList) {
                shares.add(share.getName());
            }
            ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(),
                    android.R.layout.simple_spinner_item, shares);
            spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(spinnerAdapter);

            final RadioButton newRB = (RadioButton) dialog.findViewById(R.id.radioBtn_new);
            RadioButton existingRB = (RadioButton) dialog.findViewById(R.id.radioBtn_existing);
            if (shares.size() == 0)
                existingRB.setVisibility(View.GONE);
            (newRB).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    name.setVisibility(View.VISIBLE);
                    spinner.setVisibility(View.GONE);
                }
            });

            (existingRB).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    name.setVisibility(View.GONE);
                    spinner.setVisibility(View.VISIBLE);
                }
            });

            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(this);

            Button addPurchaseBtn = (Button) dialog.findViewById(R.id.add_purchase_btn);
            addPurchaseBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Share share = new Share();
                    share.setId(databaseHandler.getNextKey("share"));
                    share.setPurchases(new RealmList<Purchase>());
                    Purchase purchase = new Purchase();
                    purchase.setId(databaseHandler.getNextKey("purchase"));

                    if (newRB.isChecked()) {
                        String sName = name.getText().toString().trim();
                        if (sName.equals("")) {
                            Toast.makeText(getActivity(), "Invalid Name", Toast.LENGTH_SHORT).show();
                            return;
                        } else {
                            share.setName(sName);
                            purchase.setName(sName);
                        }
                    }

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

                    EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares);
                    try {
                        purchase.setQuantity(Integer.parseInt(quantity.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText price = (EditText) dialog.findViewById(R.id.buying_price);
                    try {
                        purchase.setPrice(Double.parseDouble(price.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    purchase.setType("buy");
                    if (newRB.isChecked()) {
                        if (!databaseHandler.addShare(share, purchase)) {
                            Toast.makeText(getActivity(), "Share Already Exists", Toast.LENGTH_SHORT).show();
                            return;
                        }
                    } else {
                        purchase.setName(spinner.getSelectedItem().toString());
                        databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase);
                    }
                    setRecyclerViewAdapter();
                    dialog.dismiss();
                }
            });
        }
    });

    return root;
}

From source file:com.bitants.wally.fragments.RandomImagesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_main_swiperefresh, container, false);
    if (rootView != null) {
        super.onCreateView(rootView);
        gridView = (AutoGridView) rootView.findViewById(R.id.listview);
        swipeClearLayout = (SwipeClearLayout) rootView.findViewById(R.id.swipe_container);
        swipeClearLayout.setOnRefreshListener(this);
        swipeClearLayout.setOnSwipeListener(this);
        swipeClearLayout.setCircleColor(getAppBarColor());
        final ProgressBar progressBar = (ProgressBar) inflater.inflate(R.layout.view_custom_progressbar,
                swipeClearLayout, false);
        swipeClearLayout.setProgressBar(progressBar);

        setupAutoSizeGridView();//w  w  w  .j  ava 2 s  .  c  om
        if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) {
            Message msgObj = uiHandler.obtainMessage();
            msgObj.what = MSG_IMAGES_REQUEST_CREATE;
            msgObj.arg1 = 1;
            msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES);
            uiHandler.sendMessage(msgObj);
            currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE);
        } else {
            showLoader();
            getImages(1, null);
        }
        ((MainActivity) getActivity()).addOnFileChangedListener(this);
        ((MainActivity) getActivity()).addOnFiltersChangedListener(this);
    }
    return rootView;
}

From source file:net.olejon.mdapp.MedicationsFavoritesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_medications_favorites, container,
            false);//from  w  ww .j ava 2s  .  com

    // Activity
    mActivity = getActivity();

    // Context
    mContext = viewGroup.getContext();

    // Tools
    mTools = new MyTools(mContext);

    // Search
    mSearchEditText = (EditText) mActivity.findViewById(R.id.main_search_edittext);

    // List
    mListView = (ListView) viewGroup.findViewById(R.id.main_medications_favorites_list);
    mListViewEmpty = viewGroup.findViewById(R.id.main_medications_favorites_list_empty);

    return viewGroup;
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_spinner, 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));

    mLoadingSpinner = root.findViewById(R.id.loading_spinner);

    return root;/*from  ww w.  ja  v  a  2s  . c  o  m*/
}

From source file:com.sumatone.cloud.securecloud.Fragments.UploadFragment.java

private void init(ViewGroup rootView) {
    fileName = (TextView) rootView.findViewById(R.id.file_name);
    progress = (TextView) rootView.findViewById(R.id.progress);
    uploadButton = (Button) rootView.findViewById(R.id.upload_button);
    selectFile = (Button) rootView.findViewById(R.id.select_file);
    fileSize = (TextView) rootView.findViewById(R.id.file_size);
    uploadProgressBar = (ProgressBar) rootView.findViewById(R.id.upload_progress_bar);

}

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

@Nullable
@Override/*from   w w  w  .  j  a  v  a2 s . co  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_dashboard, 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());
    sharesRecyclerView = (RecyclerView) root.findViewById(R.id.shares_recycler_view);
    setRecyclerViewAdapter();

    return root;
}

From source file:org.alfresco.mobile.android.application.configuration.MainMenuConfigManager.java

public MainMenuConfigManager(FragmentActivity activity, ConfigService configService, ViewGroup vRoot) {
    super(activity, configService);
    if (configService != null) {
        String profileId = getCurrentProfile();
        if (profileId == null) {
            profileId = configService.getDefaultProfile().getIdentifier();
        }/*ww  w .j av a  2 s.  c  om*/
        if (configService.getProfile(profileId) != null) {
            rootMenuViewConfig = configService.getViewConfig(
                    configService.getProfile(profileId).getRootViewId(), configManager.getCurrentScope());
        }
    }
    this.vRoot = (ViewGroup) vRoot.findViewById(R.id.custom_menu_group);
}

From source file:nu.yona.app.ui.dashboard.CustomPageAdapter.java

private void showWeekChartData(ViewGroup layout, WeekActivity weekActivity) {
    YonaFontTextView goalType = (YonaFontTextView) layout.findViewById(R.id.topPanel)
            .findViewById(R.id.goalType);
    YonaFontTextView goalScore = (YonaFontTextView) layout.findViewById(R.id.topPanel)
            .findViewById(R.id.goalScore);
    YonaFontTextView goalDesc = (YonaFontTextView) layout.findViewById(R.id.topPanel)
            .findViewById(R.id.goalDesc);
    if (weekActivity != null) {
        goalType.setText(R.string.score);
        goalDesc.setText(R.string.week_score);

        for (WeekDayActivity weekDayActivity : weekActivity.getWeekDayActivity()) {
            WeekDayEnum weekDayEnum = weekDayActivity.getWeekDayEnum();
            View view = null;/*from   w  w w  .  j a  va  2 s . c  o m*/
            switch (weekDayEnum) {
            case SUNDAY:
                view = layout.findViewById(R.id.weekScoreControl).findViewById(R.id.weekday_first);
                view.setTag(weekActivity.getDayActivities().getSUNDAY());
                break;
            case MONDAY:
                view = layout.findViewById(R.id.weekScoreControl).findViewById(R.id.weekday_second);
                view.setTag(weekActivity.getDayActivities().getMONDAY());
                break;
            case TUESDAY:
                view = layout.findViewById(R.id.weekScoreControl).findViewById(R.id.weekday_third);
                view.setTag(weekActivity.getDayActivities().getTUESDAY());
                break;
            case WEDNESDAY:
                view = layout.findViewById(R.id.weekScoreControl).findViewById(R.id.weekday_fourth);
                view.setTag(weekActivity.getDayActivities().getWEDNESDAY());
                break;
            case THURSDAY:
                view = layout.findViewById(R.id.weekScoreControl).findViewById(R.id.weekday_fifth);
                view.setTag(weekActivity.getDayActivities().getTHURSDAY());
                break;
            case FRIDAY:
                view = layout.findViewById(R.id.weekScoreControl).findViewById(R.id.weekday_sixth);
                view.setTag(weekActivity.getDayActivities().getFRIDAY());
                break;
            case SATURDAY:
                view = layout.findViewById(R.id.weekScoreControl).findViewById(R.id.weekday_seventh);
                view.setTag(weekActivity.getDayActivities().getSATURDAY());
                break;
            default:
                break;
            }

            updateTextOfCircle(view, weekDayActivity.getDay(), weekDayActivity.getDate(),
                    weekDayActivity.getColor(), weekActivity);
        }
        goalScore.setText(weekActivity.getTotalAccomplishedGoal() + "");
    }
}