Example usage for android.view.inputmethod EditorInfo IME_ACTION_DONE

List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_DONE

Introduction

In this page you can find the example usage for android.view.inputmethod EditorInfo IME_ACTION_DONE.

Prototype

int IME_ACTION_DONE

To view the source code for android.view.inputmethod EditorInfo IME_ACTION_DONE.

Click Source Link

Document

Bits of #IME_MASK_ACTION : the action key performs a "done" operation, typically meaning there is nothing more to input and the IME will be closed.

Usage

From source file:com.stoneapp.ourvlemoodle2.activities.SignInActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final List<String> permissions = new ArrayList<String>();

    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED)
        permissions.add(Manifest.permission.WRITE_CALENDAR);

    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
        permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);

    if (permissions.size() > 0) {
        ActivityCompat.requestPermissions(this, permissions.toArray(new String[permissions.size()]),
                MY_PERMISSIONS_REQUEST_MULTIPLE);
    }/*from  w  ww.j a  v a 2s .  co  m*/

    setContentView(R.layout.activity_sign_in);

    btn = (Button) findViewById(R.id.button);
    user_id = (EditText) findViewById(R.id.editTextUser);
    user_pass = (EditText) findViewById(R.id.editPassword);
    progressBar = (ProgressBar) findViewById(R.id.progressBarSignIn);
    login_help = (TextView) findViewById(R.id.login_help);

    progressBar.setIndeterminate(true);

    user_pass.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                //                    InputMethodManager inputManager = (InputMethodManager) SignInActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
                //                    inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

                signin(v);
                handled = true;
            }
            return handled;
        }
    });

    login_help.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showHelpDialog(SignInActivity.this);
        }
    });
}

From source file:ir.rasen.charsoo.view.fragment.FragmentUserRegisterOfferBusiness.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_user_register_page_two, container, false);

    editTextEmail = (EditTextFont) view.findViewById(R.id.editText_email);
    editTextPassword = (EditTextFont) view.findViewById(R.id.editText_password);
    editTextPhoneNumber = (EditTextFont) view.findViewById(R.id.editText_PhoneNumber);

    editTextEmail.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override/*from  w ww.  j ava 2s . c o m*/
        public boolean onEditorAction(TextView textView, int actionID, KeyEvent keyEvent) {
            boolean handeled = true;
            if (actionID == EditorInfo.IME_ACTION_NEXT) {
                if (editTextPassword.getText().toString().isEmpty()) {
                    editTextPassword.requestFocus();
                } else if (editTextPhoneNumber.getText().toString().isEmpty()) {
                    editTextPhoneNumber.requestFocus();
                } else {
                    InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
                            .getSystemService(Activity.INPUT_METHOD_SERVICE);
                    inputMethodManager.hideSoftInputFromWindow(editTextEmail.getWindowToken(), 0);
                    ((ActivityUserRegister) getActivity()).onDoneButtonPressed(TAG);
                }
            }
            return handeled;
        }
    });

    editTextPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionID, KeyEvent keyEvent) {
            boolean handeled = true;
            if (actionID == EditorInfo.IME_ACTION_NEXT) {
                if (editTextPhoneNumber.getText().toString().isEmpty()) {
                    editTextPhoneNumber.requestFocus();
                } else if (editTextEmail.getText().toString().isEmpty()) {
                    editTextEmail.requestFocus();
                } else {
                    InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
                            .getSystemService(Activity.INPUT_METHOD_SERVICE);
                    inputMethodManager.hideSoftInputFromWindow(editTextPassword.getWindowToken(), 0);
                    ((ActivityUserRegister) getActivity()).onDoneButtonPressed(TAG);
                }
            }
            return handeled;
        }
    });

    editTextPhoneNumber.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionID, KeyEvent keyEvent) {
            boolean handeled = true;
            if (actionID == EditorInfo.IME_ACTION_DONE) {
                InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
                        .getSystemService(Activity.INPUT_METHOD_SERVICE);
                inputMethodManager.hideSoftInputFromWindow(editTextPhoneNumber.getWindowToken(), 0);
                ((ActivityUserRegister) getActivity()).onDoneButtonPressed(TAG);
            }
            return handeled;
        }
    });

    editTextEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                editTextEmail.setHint("");
            } else {
                editTextEmail.setHint(getActivity().getString(R.string.email_field_hint));
                //                    if (editTextName.getText().toString().equals("")) {
                //                        editTextUserIdentifier.setHint(getActivity().getString(R.string.identifier_field_hint));
                //                    }
            }
        }
    });

    editTextPassword.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                editTextPassword.setHint("");
            } else {
                editTextPassword.setHint(getActivity().getString(R.string.password_field_hint));
                //                    if (editTextName.getText().toString().equals("")) {
                //                        editTextUserIdentifier.setHint(getActivity().getString(R.string.identifier_field_hint));
                //                    }
            }
        }
    });

    editTextPhoneNumber.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                editTextPhoneNumber.setHint("");
            } else {
                editTextPhoneNumber.setHint(getActivity().getString(R.string.mobile));
                //                    if (editTextName.getText().toString().equals("")) {
                //                        editTextUserIdentifier.setHint(getActivity().getString(R.string.identifier_field_hint));
                //                    }
            }
        }
    });

    /*String ss=getActivity().getString(R.string.licenseAgreementEnglish);
    SpannableString licenseInEnglish = new SpannableString(ss);
    ClickableSpan clickableSpan = new ClickableSpan() {
            @Override
            public void onClick(View textView) {
    //                                navigate to license in persian
            }
    };
    int leftIndex=ss.indexOf("Privacy");
    int rightIndex=ss.length();
    licenseInEnglish.setSpan(clickableSpan, leftIndex, rightIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    licenseInEnglish.setSpan(new StyleSpan(Typeface.NORMAL), 0, ss.length(), 0);
    licenseInEnglish.setSpan(new StyleSpan(Typeface.BOLD), leftIndex, rightIndex, 0);
    licenseInEnglish.setSpan(new StyleSpan(Typeface.ITALIC), leftIndex, rightIndex, 0);
    englishLicenseTextView=(TextViewFont) view.findViewById(R.id.licensesInEnglish);
    englishLicenseTextView.setText(licenseInEnglish);
    englishLicenseTextView.setMovementMethod(LinkMovementMethod.getInstance());*/
    //                persianLicenseTextView=(TextViewFont) view.findViewById(R.id.licensesInPersian);
    //                persianLicenseTextView.setText(licenseInEnglish);
    //                persianLicenseTextView.setMovementMethod(LinkMovementMethod.getInstance());
    return view;

}

From source file:org.hedgewars.hedgeroid.util.TextInputDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        dialogId = savedInstanceState.getInt(BUNDLE_DIALOG_ID, dialogId);
        titleText = savedInstanceState.getInt(BUNDLE_TITLE_TEXT, titleText);
        messageText = savedInstanceState.getInt(BUNDLE_MESSAGE_TEXT, messageText);
        hintText = savedInstanceState.getInt(BUNDLE_HINT_TEXT, hintText);
    }/*from w  w w  .  jav  a 2s  .c  om*/

    final EditText editText = new EditText(getActivity());
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    if (titleText != 0) {
        builder.setTitle(titleText);
    }
    if (messageText != 0) {
        builder.setTitle(messageText);
    }
    if (hintText != 0) {
        editText.setHint(hintText);
    }

    editText.setId(android.R.id.text1);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    editText.setSingleLine();

    builder.setView(editText);
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    editText.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            listener.onTextInputDialogSubmitted(dialogId, v.getText().toString());
            dismiss();
            return true;
        }
    });

    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            listener.onTextInputDialogSubmitted(dialogId, editText.getText().toString());
        }
    });

    return builder.create();
}

From source file:net.simno.klingar.ui.LoginController.java

@OnEditorAction(R.id.password_edit)
boolean onPasswordEditorAction(TextView view, int actionId, KeyEvent event) {
    if ((event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
            || (actionId == EditorInfo.IME_ACTION_DONE)) {
        login();//from  w ww  . ja  va2s  .co  m
        return true;
    }
    return false;
}

From source file:pl.bcichecki.rms.client.android.dialogs.RegisterDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    context = getActivity();/*from   w ww  .j a v  a2  s. co m*/

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(getString(R.string.dialog_register_title));
    builder.setMessage(getString(R.string.dialog_register_message));

    final EditText usernameEditText = new EditText(getActivity());
    usernameEditText.setHint(getString(R.string.dialog_register_enter_username_hint));
    usernameEditText.setMaxLines(1);
    usernameEditText.setSingleLine();
    usernameEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    usernameEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            usernameEditText.setError(null);
        }

    });

    final EditText passwordEditText = new EditText(getActivity());
    passwordEditText.setHint(getString(R.string.dialog_register_enter_password_hint));
    passwordEditText.setMaxLines(1);
    passwordEditText.setSingleLine();
    passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    passwordEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            passwordEditText.setError(null);
        }

    });

    final EditText emailEditText = new EditText(getActivity());
    emailEditText.setHint(getString(R.string.dialog_register_enter_email_hint));
    emailEditText.setMaxLines(1);
    emailEditText.setSingleLine();
    emailEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    emailEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            emailEditText.setError(null);
        }

    });

    final LinearLayout layout = new LinearLayout(getActivity());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setGravity(Gravity.CENTER_HORIZONTAL);
    int space = (int) AppUtils.convertDpToPixel(getActivity(), 16);
    layout.setPadding(space, 0, space, 0);

    layout.addView(usernameEditText);
    layout.addView(passwordEditText);
    layout.addView(emailEditText);

    builder.setView(layout);

    builder.setPositiveButton(getString(R.string.dialog_register_ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            return;
        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {
            utilitiesRestClient = new UtilitiesRestClient(getActivity(),
                    SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(),
                    SharedPreferencesWrapper.getWebserviceContextPath());

            final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            positiveButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (!AppUtils.checkInternetConnection(getActivity())) {
                        Log.d(TAG, "There is NO network connected!");
                        return;
                    }

                    usernameEditText.setError(null);
                    passwordEditText.setError(null);
                    emailEditText.setError(null);

                    if (StringUtils.isBlank(usernameEditText.getText().toString())) {
                        usernameEditText.setError(getString(R.string.dialog_register_field_required));
                        return;
                    }
                    if (StringUtils.isBlank(passwordEditText.getText().toString())) {
                        passwordEditText.setError(getString(R.string.dialog_register_field_required));
                        return;
                    }
                    if (StringUtils.isBlank(emailEditText.getText().toString())) {
                        emailEditText.setError(getString(R.string.dialog_register_field_required));
                        return;
                    }
                    if (!AppUtils.validateEmail(emailEditText.getText().toString())) {
                        emailEditText.setError(getString(R.string.dialog_register_email_not_valid));
                        return;
                    }

                    final User user = new User();
                    user.setUsername(usernameEditText.getText().toString());
                    user.setPassword(SecurityUtils.hashSHA512Base64(passwordEditText.getText().toString()));
                    user.setEmail(StringUtils.lowerCase(emailEditText.getText().toString()));
                    user.setAddress(new AddressData());

                    utilitiesRestClient.registerUser(user, new AsyncHttpResponseHandler() {

                        @Override
                        public void onFailure(Throwable error, String content) {
                            Log.d(TAG,
                                    "Registering user failed. [error= " + error + ", content=" + content + "]");
                            AppUtils.showCenteredToast(context, getString(R.string.dialog_register_failed),
                                    Toast.LENGTH_LONG);
                        }

                        @Override
                        public void onFinish() {
                            positiveButton.setEnabled(true);
                        }

                        @Override
                        public void onStart() {
                            Log.d(TAG, "Registering user: " + user.toString());
                            AppUtils.showCenteredToast(context, getString(R.string.dialog_register_in_progress),
                                    Toast.LENGTH_SHORT);
                            positiveButton.setEnabled(false);
                        }

                        @Override
                        public void onSuccess(int statusCode, String content) {
                            Log.d(TAG, "Registered user successfully.");
                            AppUtils.showCenteredToast(context, getString(R.string.dialog_register_successful),
                                    Toast.LENGTH_SHORT);

                            SharedPreferencesWrapper.setUsername(user.getUsername());
                            SharedPreferencesWrapper.setPasswordHash(user.getPassword());
                            SharedPreferencesWrapper.setRememberUser(true);

                            dialog.dismiss();
                        }

                    });

                }
            });

            final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
            negativeButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    cancelRequests();
                    dialog.dismiss();
                }
            });

        }
    });

    return dialog;
}

From source file:com.github.riotopsys.shoppinglist.activity.ListItemEdit.java

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
        makeChange(v);/*from  ww  w .j  a va 2  s.c  o m*/
        return true;
    }
    return false;
}

From source file:org.jorge.lolin1.ui.activities.ChatRoomActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar actionBar = getActionBar();
    friendName = null;//from  ww w. j  a  v  a2s .co  m
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(Boolean.TRUE);
        actionBar.setTitle(friendName = getIntent().getStringExtra(ChatOverviewActivity.KEY_FRIEND_NAME));
        try {
            actionBar
                    .setLogo(
                            Drawable.createFromPath(
                                    ProfileCacheableBitmapLoader
                                            .getPathByID(getApplicationContext(),
                                                    FriendManager.getInstance().findFriendByName(friendName)
                                                            .getStatus().getProfileIconId())
                                            .getAbsolutePath()));
        } catch (NullPointerException ex) {
            startActivity(new Intent(getApplicationContext(), ChatOverviewActivity.class));//Clicking notification with app closed
            finish();
            return;
        }
        actionBar.setDisplayUseLogoEnabled(Boolean.TRUE);
    }
    ChatNotificationManager.dismissNotifications(getApplicationContext(), friendName);
    setContentView(R.layout.activity_chat_room);

    final EditText messageContentsTextField = (EditText) findViewById(android.R.id.inputArea);

    messageContentsTextField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId != EditorInfo.IME_ACTION_DONE)
                return Boolean.FALSE;
            String contents = messageContentsTextField.getText().toString();
            if (TextUtils.isEmpty(contents))
                return Boolean.TRUE;
            adapter.add(new ChatMessageWrapper(contents, System.currentTimeMillis()));
            sendMessage(contents, friendName);
            messageContentsTextField.setText("");
            messageContentsTextField.requestFocus();
            return Boolean.TRUE;
        }

        private void sendMessage(String contents, String friendName) {
            new AsyncTask<String, Void, Void>() {
                @Override
                protected Void doInBackground(String... params) {
                    Friend target;
                    ChatMessageWrapper messageWrapper = new ChatMessageWrapper(params[0],
                            System.currentTimeMillis());
                    logString("debug", "Sending message " + params[0] + " to " + params[1]);
                    ChatBundleManager.addMessageToFriendChat(messageWrapper,
                            target = FriendManager.getInstance().findFriendByName(params[1]));
                    scrollListViewToBottom();
                    target.sendMessage(params[0]);
                    return null;
                }
            }.executeOnExecutor(Executors.newSingleThreadExecutor(), contents, friendName);
        }
    });

    conversationListView = (ListView) findViewById(android.R.id.list);
    conversationListView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);

    logString("debug", "Calling adapter constructor");
    adapter = new ChatRoomAdapter(getApplicationContext(),
            FriendManager.getInstance().findFriendByName(friendName));

    if (!TextUtils.isEmpty(friendName))
        conversationListView.setAdapter(adapter);

    scrollListViewToBottom();

    registerLocalBroadcastReceiver();
    scrollListViewToBottom();
}

From source file:org.openlmis.core.view.activity.LoginActivity.java

private void initUI() {
    ivVisibilityPwd.setOnClickListener(this);
    btnLogin.setOnClickListener(this);

    String lastLoginUser = SharedPreferenceMgr.getInstance().getLastLoginUser();
    if (StringUtils.isNotBlank(lastLoginUser)) {
        etUsername.setText(lastLoginUser);
        etPassword.requestFocus();/* w w  w . ja v  a 2  s.  c o m*/
    }

    etPassword.setImeOptions(EditorInfo.IME_ACTION_DONE);
    etPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                hideImm();
                startLogin();
                return true;
            }
            return false;
        }
    });

    if (BuildConfig.DEBUG) {
        setDeveloperMode();
    }
}

From source file:ir.rasen.charsoo.view.fragment.user_register.FragmentUserRegisterPageTwo.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_register_user_page_two, container, false);

    editTextEmail = (EditTextFont) view.findViewById(R.id.editText_email);
    editTextPassword = (EditTextFont) view.findViewById(R.id.editText_password);
    editTextPhoneNumber = (EditTextFont) view.findViewById(R.id.editText_PhoneNumber);

    editTextEmail.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override/*from   w w w . ja  v a 2  s  . c  o m*/
        public boolean onEditorAction(TextView textView, int actionID, KeyEvent keyEvent) {
            boolean handeled = true;
            if (actionID == EditorInfo.IME_ACTION_NEXT) {
                if (editTextPassword.getText().toString().isEmpty()) {
                    editTextPassword.requestFocus();
                } else if (editTextPhoneNumber.getText().toString().isEmpty()) {
                    editTextPhoneNumber.requestFocus();
                } else {
                    InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
                            .getSystemService(Activity.INPUT_METHOD_SERVICE);
                    inputMethodManager.hideSoftInputFromWindow(editTextEmail.getWindowToken(), 0);
                    ((ActivityUserRegister) getActivity()).onDoneButtonPressed(TAG);
                }
            }
            return handeled;
        }
    });

    editTextPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionID, KeyEvent keyEvent) {
            boolean handeled = true;
            if (actionID == EditorInfo.IME_ACTION_NEXT) {
                if (editTextPhoneNumber.getText().toString().isEmpty()) {
                    editTextPhoneNumber.requestFocus();
                } else if (editTextEmail.getText().toString().isEmpty()) {
                    editTextEmail.requestFocus();
                } else {
                    InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
                            .getSystemService(Activity.INPUT_METHOD_SERVICE);
                    inputMethodManager.hideSoftInputFromWindow(editTextPassword.getWindowToken(), 0);
                    ((ActivityUserRegister) getActivity()).onDoneButtonPressed(TAG);
                }
            }
            return handeled;
        }
    });

    editTextPhoneNumber.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionID, KeyEvent keyEvent) {
            boolean handeled = true;
            if (actionID == EditorInfo.IME_ACTION_DONE) {
                InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
                        .getSystemService(Activity.INPUT_METHOD_SERVICE);
                inputMethodManager.hideSoftInputFromWindow(editTextPhoneNumber.getWindowToken(), 0);
                ((ActivityUserRegister) getActivity()).onDoneButtonPressed(TAG);
            }
            return handeled;
        }
    });

    editTextEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                //                    editTextEmail.setHint("");
            } else {
                editTextEmail.setHint(getActivity().getString(R.string.email_field_hint));
                //                    if (editTextName.getText().toString().equals("")) {
                //                        editTextUserIdentifier.setHint(getActivity().getString(R.string.identifier_field_hint));
                //                    }
            }
        }
    });

    editTextPassword.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                //                    editTextPassword.setHint("");
            } else {
                editTextPassword.setHint(getActivity().getString(R.string.password));
                //                    if (editTextName.getText().toString().equals("")) {
                //                        editTextUserIdentifier.setHint(getActivity().getString(R.string.identifier_field_hint));
                //                    }
            }
        }
    });

    editTextPhoneNumber.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                //                    editTextPhoneNumber.setHint("");
            } else {
                editTextPhoneNumber.setHint(getActivity().getString(R.string.mobile));
                //                    if (editTextName.getText().toString().equals("")) {
                //                        editTextUserIdentifier.setHint(getActivity().getString(R.string.identifier_field_hint));
                //                    }
            }
        }
    });

    /*String ss=getActivity().getString(R.string.licenseAgreementEnglish);
    SpannableString licenseInEnglish = new SpannableString(ss);
    ClickableSpan clickableSpan = new ClickableSpan() {
            @Override
            public void onClick(View textView) {
    //                                navigate to license in persian
            }
    };
    int leftIndex=ss.indexOf("Privacy");
    int rightIndex=ss.length();
    licenseInEnglish.setSpan(clickableSpan, leftIndex, rightIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    licenseInEnglish.setSpan(new StyleSpan(Typeface.NORMAL), 0, ss.length(), 0);
    licenseInEnglish.setSpan(new StyleSpan(Typeface.BOLD), leftIndex, rightIndex, 0);
    licenseInEnglish.setSpan(new StyleSpan(Typeface.ITALIC), leftIndex, rightIndex, 0);
    englishLicenseTextView=(TextViewFont) view.findViewById(R.id.licensesInEnglish);
    englishLicenseTextView.setText(licenseInEnglish);
    englishLicenseTextView.setMovementMethod(LinkMovementMethod.getInstance());*/
    //                persianLicenseTextView=(TextViewFont) view.findViewById(R.id.licensesInPersian);
    //                persianLicenseTextView.setText(licenseInEnglish);
    //                persianLicenseTextView.setMovementMethod(LinkMovementMethod.getInstance());

    (view.findViewById(R.id.licensesInEnglish)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openTermsOfServicesLink();
        }
    });

    (view.findViewById(R.id.licensesInPersian)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openTermsOfServicesLink();
        }
    });

    return view;

}

From source file:com.openerp.base.login.Login.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);/*from   ww  w.  j a va2s  .  c o  m*/
    this.context = getActivity();
    scope = new AppScope(this);

    // Inflate the layout for this fragment
    rootView = inflater.inflate(R.layout.fragment_login, container, false);
    dbListSpinner = (Spinner) rootView.findViewById(R.id.lstDatabases);
    this.handleArguments((Bundle) getArguments());
    this.loadDatabaseList();
    getActivity().setTitle(R.string.label_login);
    getActivity().getActionBar().setDisplayHomeAsUpEnabled(false);
    getActivity().getActionBar().setHomeButtonEnabled(false);
    edtUsername = (EditText) rootView.findViewById(R.id.edtUsername);
    edtPassword = (EditText) rootView.findViewById(R.id.edtPassword);
    edtPassword.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                goNext();
            }
            return false;
        }
    });
    return rootView;
}