Example usage for android.view View findViewById

List of usage examples for android.view View findViewById

Introduction

In this page you can find the example usage for android.view View 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.ymt.demo1.main.sign.SignUpFragment.java

/**
 * ???//w  w w  . j  a  v a  2 s . co  m
 * ?????????
 */
protected void initView(View view) {
    /*
    
     */
    //?
    final EditText phoneTxt = (EditText) view.findViewById(R.id.input_phone_num);
    final EditText accountTxt = (EditText) view.findViewById(R.id.input_account);
    final EditText pswTxt = (EditText) view.findViewById(R.id.input_psw);
    final EditText rePswTxt = (EditText) view.findViewById(R.id.re_input_psw);
    final TextView licenseTxt = (TextView) view.findViewById(R.id.licence_txt);
    /*???? ??
     */
    final TextView getCheckNums = (TextView) view.findViewById(R.id.get_check_nums);
    final EditText inputCheckNums = (EditText) view.findViewById(R.id.input_check_nums);
    getCheckNums.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //todo ????

        }
    });

    /**
     *  todo spannableString 
     *   ?
     */
    SpannableString spannableString = new SpannableString(getString(R.string.license));
    ForegroundColorSpan span = new ForegroundColorSpan(getResources().getColor(R.color.material_blue_grey_800));
    spannableString.setSpan(span, 0, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    licenseTxt.setText(spannableString);
    //switch(??)
    myCheckView = (MyCheckView) view.findViewById(R.id.switch_liscense);
    //
    Button signUpBtn = (Button) view.findViewById(R.id.do_sign_btn);
    signUpBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //
            String phoneNum = phoneTxt.getText().toString();
            String account = accountTxt.getText().toString();
            String psw = pswTxt.getText().toString();
            String rePsw = rePswTxt.getText().toString();
            //??
            String checkNums = inputCheckNums.getText().toString();
            //todo if(){}else{} ??

            if (!TextUtils.isEmpty(phoneNum) && !TextUtils.isEmpty(account) && !TextUtils.isEmpty(psw)
                    && psw.equals(rePsw)) {
                //?
                if (myCheckView.isChecked()) {
                    queue.add(signUpRequest(account, psw, phoneNum, NORMAL_USER));
                } else {
                    Toast.makeText(getActivity(), "?????",
                            Toast.LENGTH_SHORT).show();
                }

            } else if (TextUtils.isEmpty(phoneNum)) {
                //???
                Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT).show();
            } else if (TextUtils.isEmpty(account)) {
                //???
                Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT).show();
            } else {
                //???
                Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    });

    LinearLayout licence = (LinearLayout) view.findViewById(R.id.liscense_layout);
    licence.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            myCheckView.callOnClick();
        }
    });
}

From source file:de.awisus.refugeeaidleipzig.views.map.FragmentKarte.java

/**
 * Automatically called method inflating the xml-layout
 * Sets actovoty title to Map/*from  w ww .j  av  a  2s . com*/
 * @param inflater who cares
 * @param container who cares
 * @param savedInstanceState who cares
 * @return View inflated with the layout
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_karte, container, false);

    fabUpdate = (FloatingActionButton) view.findViewById(R.id.fabUpdate);
    fabUpdate.setOnClickListener(this);

    fabHide = AnimationUtils.loadAnimation(context, R.anim.bt_hide);
    fabShow = AnimationUtils.loadAnimation(context, R.anim.bt_show);

    getActivity().setTitle(R.string.app_name);
    return view;
}

From source file:com.hybris.mobile.app.commerce.fragment.CheckoutFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mPaymentsDetails = new ArrayList<>();
    mAddPayment = view.findViewById(R.id.checkout_add_payment);
    mPaymentSpinner = (Spinner) view.findViewById(R.id.checkout_account_payment_spinner);
    mPaymentAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item,
            new ArrayList<String>());
    mPaymentSpinner.setAdapter(mPaymentAdapter);
    mPaymentSpinner.setOnItemSelectedListener(mPaymentSpinnerListener);

    mAddPayment.setOnClickListener(new View.OnClickListener() {
        @Override/* ww  w . j  av a 2 s  .c  o  m*/
        public void onClick(View v) {
            showCreatePaymentView();
        }
    });
}

From source file:com.jiandanbaoxian.fragment.HistoryPriceDetailFragmentTab1.java

private void setUp(View view, Bundle savedInstanceState) {
    context = HistoryPriceDetailFragmentTab1.this.getActivity();
    userid = PreferenceUtil.load(context, PreferenceConstant.userid, -1);

    tv_csx_price = (TextView) view.findViewById(R.id.tv_csx_price);
    tv_szx_price = (TextView) view.findViewById(R.id.tv_szx_price);
    tv_zwx_price = (TextView) view.findViewById(R.id.tv_zwx_price);
    tv_jmpx_price = (TextView) view.findViewById(R.id.tv_bjmpx_price);
    tv_jqx_price = (TextView) view.findViewById(R.id.tv_jqx_price);
    tv_cqx_price = (TextView) view.findViewById(R.id.tv_cqx_price);
    tv_total_price = (TextView) view.findViewById(R.id.tv_total_price);

    cb_csx = (CheckBox) view.findViewById(R.id.cb_csx);
    cb_zwx = (CheckBox) view.findViewById(R.id.cb_zwx);
    cb_szx = (CheckBox) view.findViewById(R.id.cb_szx);
    cb_jqx = (CheckBox) view.findViewById(R.id.cb_jqx);
    cb_bjmpx = (CheckBox) view.findViewById(R.id.cb_bjmpx);
    cb_ccx = (CheckBox) view.findViewById(R.id.cb_ccx);

    cb_csx.setChecked(true);//from  ww  w . j  a va2  s. com
    cb_zwx.setChecked(true);
    cb_szx.setChecked(true);
    cb_jqx.setChecked(true);
    cb_bjmpx.setChecked(true);
    cb_ccx.setChecked(true);

    cb_agree_license = (CheckBox) view.findViewById(R.id.cb_agree_license);
    cb_agree_license.setChecked(true);

    tv_i_want_to_rebuy_insurance = (TextView) view.findViewById(R.id.tv_i_want_to_rebuy_insurance);

}

From source file:com.ymt.demo1.plates.news.FileNoticeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_scrollview_ultra_list_view, container, false);
    scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
    Fragment parentFragment = getParentFragment();
    ViewGroup viewGroup = (ViewGroup) parentFragment.getView();
    if (viewGroup != null) {
        scrollView.setTouchInterceptionViewGroup((ViewGroup) viewGroup.findViewById(R.id.container));
        if (parentFragment instanceof ObservableScrollViewCallbacks) {
            scrollView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentFragment);
        }/*w  ww  . ja  v  a  2  s  .  c  o m*/
    }

    initView(view);
    return view;
}

From source file:org.deviceconnect.android.uiapp.fragment.profile.PhoneProfileFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    View view = inflater.inflate(R.layout.fragment_phone_service, container, false);
    view.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    final TextView num = (TextView) view.findViewById(R.id.fragment_phone_number);

    final OnClickListener l = new OnClickListener() {
        @Override//from  w  w w. j  av  a2s.  c  o  m
        public void onClick(final View v) {
            String phone = num.getText().toString();
            int id = v.getId();
            if (id == R.id.fragment_phone_1) {
                phone += "1";
            } else if (id == R.id.fragment_phone_2) {
                phone += "2";
            } else if (id == R.id.fragment_phone_3) {
                phone += "3";
            } else if (id == R.id.fragment_phone_4) {
                phone += "4";
            } else if (id == R.id.fragment_phone_5) {
                phone += "5";
            } else if (id == R.id.fragment_phone_6) {
                phone += "6";
            } else if (id == R.id.fragment_phone_7) {
                phone += "7";
            } else if (id == R.id.fragment_phone_8) {
                phone += "8";
            } else if (id == R.id.fragment_phone_9) {
                phone += "9";
            } else if (id == R.id.fragment_phone_a) {
                phone += "*";
            } else if (id == R.id.fragment_phone_0) {
                phone += "0";
            } else if (id == R.id.fragment_phone_s) {
                phone += "#";
            } else if (id == R.id.fragment_phone_clear) {
                phone = "";
            }
            num.setText(phone);
        }
    };

    int[] ids = { R.id.fragment_phone_1, R.id.fragment_phone_2, R.id.fragment_phone_3, R.id.fragment_phone_4,
            R.id.fragment_phone_5, R.id.fragment_phone_6, R.id.fragment_phone_7, R.id.fragment_phone_8,
            R.id.fragment_phone_9, R.id.fragment_phone_a, R.id.fragment_phone_0, R.id.fragment_phone_s,
            R.id.fragment_phone_clear };

    for (int i = 0; i < ids.length; i++) {
        Button btn = (Button) view.findViewById(ids[i]);
        btn.setOnClickListener(l);
    }

    Button send = (Button) view.findViewById(R.id.fragment_phone_send);
    send.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            callPhone(num.getText().toString());
        }
    });
    return view;
}

From source file:com.breadwallet.presenter.fragments.MainFragmentQR.java

private void setTipsPositions(final View rootView) {
    new Handler().postDelayed(new Runnable() {
        @Override/* w w  w  .  j a  v  a2s .  c  o m*/
        public void run() {
            View temp = rootView.findViewById(R.id.qr_image_address_layout);
            int qrBubble1Position = temp == null ? MainActivity.screenParametersPoint.y / 2
                    : temp.getHeight() / 3 + temp.getHeight() / 10;
            int qrBubble2Position = temp == null ? MainActivity.screenParametersPoint.y / 2
                    : temp.getHeight() - temp.getHeight() / 7;
            BRTipsManager.setQrBubblesPosition(qrBubble1Position, qrBubble2Position);
        }
    }, 200);
}

From source file:com.QuarkLabs.BTCeClient.fragments.OrdersBookFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);//from  w  ww.j a v a 2  s  .com
    @SuppressLint("InflateParams")
    View v = inflater.inflate(R.layout.fragment_ordersbook, container, false);
    mAsksList = (ListView) v.findViewById(R.id.asks);
    mBidsList = (ListView) v.findViewById(R.id.bids);
    mChartArea = (FrameLayout) v.findViewById(R.id.OrdersBookChart);
    mLoadingViewAsks = new ProgressBar(getActivity());
    mLoadingViewBids = new ProgressBar(getActivity());
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    lp.gravity = Gravity.CENTER;
    mLoadingViewAsks.setLayoutParams(lp);

    mLoadingViewBids.setLayoutParams(lp);
    ((LinearLayout) mAsksList.getParent()).addView(mLoadingViewAsks);
    mAsksList.setEmptyView(mLoadingViewAsks);
    ((LinearLayout) mBidsList.getParent()).addView(mLoadingViewBids);
    mBidsList.setEmptyView(mLoadingViewBids);

    ActionBarActivity hostActivity = (ActionBarActivity) getActivity();
    hostActivity.getSupportActionBar().setCustomView(mPairsSpinner, new ActionBar.LayoutParams(Gravity.END));
    hostActivity.getSupportActionBar().setDisplayShowCustomEnabled(true);
    return v;
}

From source file:gov.in.bloomington.georeporter.fragments.ReportFragment.java

/**
 * Inflates the appropriate view for each datatype
 * //www.  j a v  a 2  s .c  o  m
 * @param attribute
 * @param savedInstanceState
 * @return
 * View
 */
private View loadViewForAttribute(JSONObject attribute, Bundle savedInstanceState) {
    LayoutInflater inflater = getLayoutInflater(savedInstanceState);
    String datatype = attribute.optString(Open311.DATATYPE, Open311.STRING);

    if (datatype.equals(Open311.STRING) || datatype.equals(Open311.NUMBER) || datatype.equals(Open311.TEXT)) {
        View v = inflater.inflate(R.layout.list_item_report_attributes_string, null);
        EditText input = (EditText) v.findViewById(R.id.input);

        if (datatype.equals(Open311.NUMBER)) {
            input.setInputType(InputType.TYPE_CLASS_NUMBER);
        }
        if (datatype.equals(Open311.TEXT)) {
            input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
        }
        return v;
    } else if (datatype.equals(Open311.DATETIME)) {
        View v = inflater.inflate(R.layout.list_item_report_attributes_datetime, null);
        TextView input = (TextView) v.findViewById(R.id.input);
        input.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                SherlockDialogFragment picker = new DatePickerDialogFragment(v);
                picker.show(getActivity().getSupportFragmentManager(), "datePicker");
            }
        });
        return v;
    } else if (datatype.equals(Open311.SINGLEVALUELIST) || datatype.equals(Open311.MULTIVALUELIST)) {
        JSONArray values = attribute.optJSONArray(Open311.VALUES);
        int len = values.length();

        if (datatype.equals(Open311.SINGLEVALUELIST)) {
            View v = inflater.inflate(R.layout.list_item_report_attributes_singlevaluelist, null);
            RadioGroup input = (RadioGroup) v.findViewById(R.id.input);
            for (int i = 0; i < len; i++) {
                JSONObject value = values.optJSONObject(i);
                RadioButton button = (RadioButton) inflater.inflate(R.layout.radiobutton, null);
                button.setText(value.optString(Open311.KEY));
                input.addView(button);
            }
            return v;
        } else if (datatype.equals(Open311.MULTIVALUELIST)) {
            View v = inflater.inflate(R.layout.list_item_report_attributes_multivaluelist, null);
            LinearLayout input = (LinearLayout) v.findViewById(R.id.input);
            for (int i = 0; i < len; i++) {
                JSONObject value = values.optJSONObject(i);
                CheckBox checkbox = (CheckBox) inflater.inflate(R.layout.checkbox, null);
                checkbox.setText(value.optString(Open311.KEY));
                input.addView(checkbox);
            }
            return v;
        }
    }
    return null;
}

From source file:gov.in.bloomington.georeporter.fragments.ReportFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        try {//  w ww  .  j av  a2 s.  c om
            JSONObject s = new JSONObject(savedInstanceState.getString("service"));
            setService(s);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    View v = getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_report, container, false);
    mLocationView = (EditText) v.findViewById(R.id.address_string);

    // Register onClick handlers for all the clickables in the layout
    v.findViewById(R.id.mapChooserButton).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getActivity(), ChooseLocationActivity.class);
            startActivityForResult(i, CHOOSE_LOCATION_REQUEST);
        }
    });
    v.findViewById(R.id.button_cancel).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        }
    });
    v.findViewById(R.id.button_submit).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            submit(v);
        }
    });
    return v;
}