Example usage for android.widget LinearLayout findViewById

List of usage examples for android.widget LinearLayout findViewById

Introduction

In this page you can find the example usage for android.widget LinearLayout 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.citrus.sample.WalletPaymentFragment.java

private void showDynamicPricingPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = "Apply Dynamic Pricing";
    String positiveButtonText = "Apply";
    final Utils.DPRequestType[] dpRequestType = new Utils.DPRequestType[1];
    ScrollView scrollView = new ScrollView(getActivity());
    LinearLayout linearLayout = (LinearLayout) getActivity().getLayoutInflater()
            .inflate(R.layout.dynamic_pricing_input_layout, null);
    final EditText editTransactionAmount = (EditText) linearLayout.findViewById(R.id.edit_txn_amount);
    final EditText editCouponCode = (EditText) linearLayout.findViewById(R.id.edit_coupon_code);
    final EditText editAlteredAmount = (EditText) linearLayout.findViewById(R.id.edit_altered_amount);
    final LinearLayout layoutCouponCode = (LinearLayout) linearLayout.findViewById(R.id.layout_for_coupon_code);
    final LinearLayout layoutAlteredAmount = (LinearLayout) linearLayout
            .findViewById(R.id.layout_for_altered_amount);
    Spinner spinner = (Spinner) linearLayout.findViewById(R.id.spinner_dp_request_type);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override/*w  w  w. j ava2 s.  c o m*/
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            switch (position) {
            case 0:
                dpRequestType[0] = Utils.DPRequestType.SEARCH_AND_APPLY;
                layoutCouponCode.setVisibility(View.GONE);
                layoutAlteredAmount.setVisibility(View.GONE);
                break;
            case 1:
                dpRequestType[0] = Utils.DPRequestType.CALCULATE_PRICING;
                layoutCouponCode.setVisibility(View.VISIBLE);
                layoutAlteredAmount.setVisibility(View.GONE);
                break;
            case 2:
                dpRequestType[0] = Utils.DPRequestType.VALIDATE_RULE;
                layoutCouponCode.setVisibility(View.VISIBLE);
                layoutAlteredAmount.setVisibility(View.VISIBLE);
                break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    alert.setTitle("Perform Dynamic Pricing");
    alert.setMessage(message);

    scrollView.addView(linearLayout);
    alert.setView(scrollView);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String amount = editTransactionAmount.getText().toString();
            String alteredAmount = editAlteredAmount.getText().toString();
            String couponCode = editCouponCode.getText().toString();

            mListener.onPaymentTypeSelected(dpRequestType[0], new Amount(amount), couponCode,
                    new Amount(alteredAmount));

            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editTransactionAmount.getWindowToken(), 0);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editTransactionAmount.requestFocus();
    alert.show();
}

From source file:com.sim2dial.dialer.InCallActivity.java

private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri,
        Resources resources) {//  w ww.j  a  v  a2 s.co m
    TextView contact = (TextView) callView.findViewById(R.id.contactNameOrNumber);
    if (lAddress.getDisplayName() == null) {
        if (resources.getBoolean(R.bool.only_display_username_if_unknown)
                && LinphoneUtils.isSipAddress(sipUri)) {
            contact.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
        } else {
            contact.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
        }
    } else {
        contact.setText(lAddress.getDisplayName());
    }
}

From source file:com.sim2dial.dialer.InCallActivity.java

private boolean displayCallStatusIconAndReturnCallPaused(LinearLayout callView, LinphoneCall call) {
    boolean isCallPaused, isInConference;
    ImageView callState = (ImageView) callView.findViewById(R.id.callStatus);
    callState.setTag(call);/*from  ww  w  .j  av  a2  s.c  o m*/
    callState.setOnClickListener(this);

    if (call.getState() == State.Paused || call.getState() == State.PausedByRemote
            || call.getState() == State.Pausing) {
        callState.setImageResource(R.drawable.pause);
        isCallPaused = true;
        isInConference = false;
    } else if (call.getState() == State.OutgoingInit || call.getState() == State.OutgoingProgress
            || call.getState() == State.OutgoingRinging) {
        callState.setImageResource(R.drawable.call_state_ringing_default);
        isCallPaused = false;
        isInConference = false;
    } else {
        if (isConferenceRunning && call.isInConference()) {
            callState.setImageResource(R.drawable.remove);
            isInConference = true;
        } else {
            callState.setImageResource(R.drawable.play);
            isInConference = false;
        }
        isCallPaused = false;
    }

    return isCallPaused || isInConference;
}

From source file:com.todoroo.astrid.activity.TaskListFragment.java

private void showFeedbackPrompt() {
    if (!(this instanceof TagViewFragment)
            && (DateUtilities.now() - Preferences.getLong(PREF_LAST_FEEDBACK_TIME, 0)) > FEEDBACK_TIME_INTERVAL
            && taskService.getUserActivationStatus()) {
        final LinearLayout root = (LinearLayout) getView().findViewById(R.id.taskListParent);
        if (root.findViewById(R.id.feedback_banner) == null) {
            final View feedbackPrompt = getActivity().getLayoutInflater().inflate(R.layout.feedback_prompt,
                    root, false);//w w  w.j  ava  2  s .c  o m

            feedbackPrompt.findViewById(R.id.positiveFeedback).setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        root.removeView(feedbackPrompt);
                        FeedbackPromptDialogs.showFeedbackDialog((AstridActivity) getActivity(), true);
                        Preferences.setLong(PREF_LAST_FEEDBACK_TIME, DateUtilities.now());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });

            feedbackPrompt.findViewById(R.id.negativeFeedback).setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        root.removeView(feedbackPrompt);
                        FeedbackPromptDialogs.showFeedbackDialog((AstridActivity) getActivity(), false);
                        Preferences.setLong(PREF_LAST_FEEDBACK_TIME, DateUtilities.now());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });

            root.addView(feedbackPrompt, 0);
        }
    }
}

From source file:com.sim2dial.dialer.InCallActivity.java

private void displayConferenceHeader() {
    LinearLayout conferenceHeader = (LinearLayout) inflater.inflate(R.layout.conference_header, container,
            false);/* w  w w.  j av a2  s  .  c om*/

    ImageView conferenceState = (ImageView) conferenceHeader.findViewById(R.id.conferenceStatus);
    conferenceState.setOnClickListener(this);
    if (LinphoneManager.getLc().isInConference()) {
        conferenceState.setImageResource(R.drawable.play);
    } else {
        conferenceState.setImageResource(R.drawable.pause);
    }

    callsList.addView(conferenceHeader);
}

From source file:org.linphone.InCallActivity.java

private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri,
        Resources resources) {/* ww w .  j a va  2  s . c o  m*/
    TextView contact = (TextView) callView.findViewById(R.id.contactNameOrNumber);

    Contact lContact = ContactsManager.getInstance()
            .findContactWithAddress(callView.getContext().getContentResolver(), lAddress);
    if (lContact == null) {
        if (resources.getBoolean(R.bool.only_display_username_if_unknown)
                && LinphoneUtils.isSipAddress(sipUri)) {
            contact.setText(lAddress.getUserName());
        } else {
            contact.setText(sipUri);
        }
    } else {
        contact.setText(lContact.getName());
    }
}

From source file:org.linphone.InCallActivity.java

private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, Uri thumbnailUri,
        boolean hide) {
    AvatarWithShadow contactPicture = (AvatarWithShadow) callView.findViewById(R.id.contactPicture);
    if (pictureUri != null) {
        LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture.getView(),
                Uri.parse(pictureUri.toString()), thumbnailUri, R.drawable.unknown_small);
    }//from   w ww .  j  av a 2s . c  o  m
    callView.setVisibility(hide ? View.GONE : View.VISIBLE);
}

From source file:org.xingjitong.InCallActivity.java

private void setContactPhone(LinearLayout callView, LinphoneAddress lAddress, String sipUri,
        Resources resources) {//from w w  w  . j  a v a2  s .  c om
    TextView contact = (TextView) callView.findViewById(R.id.contactNameOrNumber);
    if (lAddress.getDisplayName() == null) {
        if (resources.getBoolean(R.bool.only_display_username_if_unknown)
                && LinphoneUtils.isSipAddress(sipUri)) {
            contact.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
        } else {
            contact.setText(sipUri);
        }
    } else {
        contact.setText(lAddress.getDisplayName());
    }
    String p = contact.getText().toString();
    if (p.startsWith("01") && !p.startsWith("010")) {
        p = p.substring(1);
    } else if (p.startsWith("51201")) {
        p = p.substring(4);
    } else if (p.startsWith("512")) {
        p = p.substring(3);
    }
    if ("00000000".equals(p)) {
        p = "??";
    }
    contact.setText(p);
}

From source file:org.xingjitong.InCallActivity.java

private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, boolean hide) {
    //yyppcallingui  AvatarWithShadow-AvatarWithShadowcalling
    AvatarWithShadowcalling contactPicture = (AvatarWithShadowcalling) callView
            .findViewById(R.id.contactPicture);
    if (pictureUri != null) {
        LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture.getView(),
                Uri.parse(pictureUri.toString()), R.drawable.unknown_small); //callingcontact  //unknown_small//yyppcallingui
    }//from  w  w  w  . ja v  a 2  s  . com
    callView.setVisibility(hide ? View.GONE : View.VISIBLE);
}

From source file:com.saulcintero.moveon.fragments.Main.java

private void defineWidgets(LinearLayout fragmentView) {
    chrono = (Chronometer) fragmentView.findViewById(R.id.chrono);
    display1_icon = (ImageView) fragmentView.findViewById(R.id.practice_display1_icon);
    display1_text1 = (TextView) fragmentView.findViewById(R.id.practice_display1_item_one);
    display1_text2 = (TextView) fragmentView.findViewById(R.id.practice_display1_item_two);
    display1_label = (TextView) fragmentView.findViewById(R.id.practice_display1_item_three);
    display2_icon = (ImageView) fragmentView.findViewById(R.id.practice_display2_icon);
    display2_text1 = (TextView) fragmentView.findViewById(R.id.practice_display2_item_one);
    display2_text2 = (TextView) fragmentView.findViewById(R.id.practice_display2_item_two);
    display2_label = (TextView) fragmentView.findViewById(R.id.practice_display2_item_three);
    display3_icon = (ImageView) fragmentView.findViewById(R.id.practice_display3_icon);
    display3_text1 = (TextView) fragmentView.findViewById(R.id.practice_display3_item_one);
    display3_text2 = (TextView) fragmentView.findViewById(R.id.practice_display3_item_two);
    display3_label = (TextView) fragmentView.findViewById(R.id.practice_display3_item_three);
    display4_icon = (ImageView) fragmentView.findViewById(R.id.practice_display4_icon);
    display4_text1 = (TextView) fragmentView.findViewById(R.id.practice_display4_item_one);
    display4_text2 = (TextView) fragmentView.findViewById(R.id.practice_display4_item_two);
    display4_label = (TextView) fragmentView.findViewById(R.id.practice_display4_item_three);
    display5_label = (TextView) fragmentView.findViewById(R.id.practice_display5_item_one);
    display5_text1 = (TextView) fragmentView.findViewById(R.id.practice_display5_item_two);
    display5_image = (ImageView) fragmentView.findViewById(R.id.practice_display5_item_three);
    display6_text1 = (TextView) fragmentView.findViewById(R.id.practice_display6_item_one);
    display6_image = (ImageView) fragmentView.findViewById(R.id.practice_display6_item_three);
    start_button = (ImageView) fragmentView.findViewById(R.id.practice_start_image);
    pauseresume_button = (ImageView) fragmentView.findViewById(R.id.practice_pauseresume_image);
    stop_button = (ImageView) fragmentView.findViewById(R.id.practice_stop_image);
    start_text = (TextView) fragmentView.findViewById(R.id.practice_start_item);
    pauseresume_text = (TextView) fragmentView.findViewById(R.id.practice_pauseresume_item);
    stop_text = (TextView) fragmentView.findViewById(R.id.practice_stop_item);
    coach_button = (ImageView) fragmentView.findViewById(R.id.main_action_bar_item_one);
    follow_button = (ImageView) fragmentView.findViewById(R.id.practice_mapview_followlocation);
    locked_button = (ImageView) fragmentView.findViewById(R.id.main_action_bar_item_two);
    full_mapview = (ImageButton) fragmentView.findViewById(R.id.practice_mapview_fullscreen);

    animationFadeIn = AnimationUtils.loadAnimation(mContext, R.anim.fadein_slow);
    animationFadeOut = AnimationUtils.loadAnimation(mContext, R.anim.fadeout_slow);
    animationFadeIn.setAnimationListener(animationInListener);
    animationFadeOut.setAnimationListener(animationOutListener);

    loadDisplays();//from ww w.j av  a  2 s  .co  m
}