Example usage for android.text InputType TYPE_TEXT_VARIATION_POSTAL_ADDRESS

List of usage examples for android.text InputType TYPE_TEXT_VARIATION_POSTAL_ADDRESS

Introduction

In this page you can find the example usage for android.text InputType TYPE_TEXT_VARIATION_POSTAL_ADDRESS.

Prototype

int TYPE_TEXT_VARIATION_POSTAL_ADDRESS

To view the source code for android.text InputType TYPE_TEXT_VARIATION_POSTAL_ADDRESS.

Click Source Link

Document

Variation of #TYPE_CLASS_TEXT : entering a postal mailing address.

Usage

From source file:com.example.android.contactslist.ui.eventEntry.EventEntryFragment.java

private void editAddressTextDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    // Set up the input
    final EditText input = new EditText(getActivity());

    input.setText(mAddressViewButton.getText());

    input.setMinHeight(50);/* w  ww. ja v a2 s  .com*/

    // Specify the type of input expected for each of the communications classes
    switch (mEventClass) {

    case EventInfo.EMAIL_CLASS:
        builder.setTitle(R.string.event_address_title);
        input.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        break;
    case EventInfo.PHONE_CLASS:
    case EventInfo.SMS_CLASS:
        builder.setTitle(R.string.event_address_title_alt_phone);
        input.setInputType(InputType.TYPE_CLASS_PHONE);
        break;
    case EventInfo.MEETING_CLASS:
        builder.setTitle(R.string.event_address_title);
        input.setInputType(InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS);
        break;
    case EventInfo.SKYPE:
    case EventInfo.GOOGLE_HANGOUTS:
    case EventInfo.FACEBOOK:

    default:
        input.setInputType(InputType.TYPE_CLASS_TEXT);
        builder.setTitle(R.string.event_address_title_alt_handle);

    }

    builder.setView(input);

    // Set up the buttons
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mAddressViewButton.setText(input.getText().toString());
        }
    });
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();
}

From source file:com.example.android.contactslist.ui.eventEntry.EventEntryFragment.java

private void addItemsToClassSpinner() {

    //set the adapter to the string-array in the strings resource
    ArrayAdapter<String> feedSelectionAdapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item,
            getResources().getStringArray(R.array.array_of_event_classes));

    //choose the style of the list.
    feedSelectionAdapter.setDropDownViewResource(android.R.layout.simple_list_item_activated_1);

    mClassSelectionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override//from   w ww  .  ja  v a  2  s  .  com
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

            mEventClass = pos + 1; // set the event class for this java class

            switch (mEventClass) {
            case EventInfo.PHONE_CLASS:
                mAddressViewButton.setText(mVoiceNumber);
                mAddressViewButton.setInputType(InputType.TYPE_CLASS_PHONE);
                mEventDurationLayout.setVisibility(View.VISIBLE);
                mEventWordCountLayout.setVisibility(View.GONE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title_alt_phone);

                break;
            case EventInfo.EMAIL_CLASS:
                mAddressViewButton.setText(mEmailAddress);
                mAddressViewButton.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
                mEventDurationLayout.setVisibility(View.GONE);
                mEventWordCountLayout.setVisibility(View.VISIBLE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title);

                break;
            case EventInfo.SMS_CLASS:
                mAddressViewButton.setText(mVoiceNumber);
                mAddressViewButton.setInputType(InputType.TYPE_CLASS_PHONE);
                mEventDurationLayout.setVisibility(View.GONE);
                mEventWordCountLayout.setVisibility(View.VISIBLE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title_alt_phone);

                break;
            case EventInfo.MEETING_CLASS:
                mAddressViewButton.setText(mStreetAddress);
                mAddressViewButton.setInputType(InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS);
                mEventDurationLayout.setVisibility(View.VISIBLE);
                mEventWordCountLayout.setVisibility(View.GONE);
                mIncomingButton.setText(R.string.incoming_title_alt);
                mOutgoingButton.setText(R.string.outgoing_title_alt);
                mAddressTitle.setText(R.string.event_address_title);

                break;
            case EventInfo.SKYPE:
                mEventDurationLayout.setVisibility(View.VISIBLE);
                mEventWordCountLayout.setVisibility(View.GONE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title_alt_handle);

                break;
            case EventInfo.GOOGLE_HANGOUTS:
                mAddressViewButton.setText(mEmailAddress);
                mAddressViewButton.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
                mEventDurationLayout.setVisibility(View.VISIBLE);
                mEventWordCountLayout.setVisibility(View.GONE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title_alt_handle);

                break;
            case EventInfo.FACEBOOK:
                mAddressViewButton.setText(mEmailAddress);
                mAddressViewButton.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
                mEventDurationLayout.setVisibility(View.GONE);
                mEventWordCountLayout.setVisibility(View.VISIBLE);
                mIncomingButton.setText(R.string.incoming_title);
                mOutgoingButton.setText(R.string.outgoing_title);
                mAddressTitle.setText(R.string.event_address_title_alt_handle);

                break;

            default:
            }

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });

    mClassSelectionSpinner.setAdapter(feedSelectionAdapter);
}