Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7853927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:51:22+00:00 2026-06-02T19:51:22+00:00

I have a simple login layout that contains two EditText fields and a Button

  • 0

I have a simple login layout that contains two EditText fields and a Button to login. The problem is that the ActionBar disappears when the soft keyboard is open and I change the focus from an EditText to the Button, and the ActionBar comes back again when I press back. The problem does not occur when the soft keyboard is closed and I navigate through the EditTexts and Button with the DPAD.

I use ActionBarSherlock, and the problem occurs only on Android 2.x emulators, on the 4.x emulators everything is normal. I know ActionBarSherlock uses the native ActionBar implementations on Android versions where it is available, so it probably is a problem with the ActionBarSherlock code.

I also executed a test to check the value of ActionBar.isShowing(), but this returned true even when the ActionBar was not visible on the screen.

I cannot figure out what is going on in this case, anybody has some ideas?

Layout XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="UselessParent" >

    <LinearLayout
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/username"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:hint="@string/username"
            android:inputType="textNoSuggestions"
            android:nextFocusUp="@+id/loginButton"
            android:imeOptions="actionNext" />

        <EditText
            android:id="@+id/password"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:hint="@string/password"
            android:inputType="textPassword"
            android:imeOptions="actionDone" />

        <Button
            android:id="@+id/loginButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:text="@string/login"
            android:textSize="20sp"
            android:nextFocusDown="@+id/username" />

    </LinearLayout>

</RelativeLayout>

FRAGMENT CODE

public class LoginFragment extends BaseFragment {

    @InjectView(R.id.loginButton) protected Button mLoginButton;
    @InjectView(R.id.username) protected EditText mUsernameEditText;
    @InjectView(R.id.password) protected EditText mPasswordEditText;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.login, container, false);
    }

    @Override
    public void onStart() {
        super.onStart();

        mLoginButton.setEnabled(allFieldsValid());
        mLoginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                handleLogin();
            }
        });

        mPasswordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE && allFieldsValid()) {
                    handleLogin();
                }
                return false;
            }
        });

        TextWatcher fieldValidatorTextWatcher = new TextWatcher() {
            @Override
            public void afterTextChanged(Editable s) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                mLoginButton.setEnabled(allFieldsValid());
            }
        };

        mUsernameEditText.addTextChangedListener(fieldValidatorTextWatcher);
        mPasswordEditText.addTextChangedListener(fieldValidatorTextWatcher);
    }

    private void handleLogin() {
        getSherlockActivity().setSupportProgressBarIndeterminateVisibility(true);

        Intent intent = new Intent(getActivity(), LoginService.class);
        intent.putExtra(BaseIntentService.EXTRA_STATUS_RECEIVER, mResultReceiver);
        intent.putExtra(LoginService.PARAM_USERNAME, mUsernameEditText.getText().toString());
        intent.putExtra(LoginService.PARAM_PASSWORD, mPasswordEditText.getText().toString());
        getActivity().startService(intent);
    }

    private boolean allFieldsValid() {
        return usernameFieldIsValid() && passwordFieldIsValid();
    }

    private boolean usernameFieldIsValid() {
        return !TextUtils.isEmpty(mUsernameEditText.getText());
    }

    private boolean passwordFieldIsValid() {
        return !TextUtils.isEmpty(mPasswordEditText.getText());
    }

    @Override
    public void onReceiveResult(int resultCode, Bundle resultData) {
        getSherlockActivity().setSupportProgressBarIndeterminateVisibility(false);
        super.onReceiveResult(resultCode, resultData);
    }

    @Override
    public void onReceiveResultSuccess(Bundle resultData) {
        ((LoginActivity) getActivity()).redirectToSelectTeamwebActivity(resultData.getInt(LoginService.RESULT_USER_ID));
    }

    @Override
    public void onReceiveResultFailure(Bundle resultData) {
        mPasswordEditText.setText("");
        String errorMessage = getString(R.string.invalid_login_credentials);
        Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_LONG).show();
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:51:27+00:00Added an answer on June 2, 2026 at 7:51 pm

    ActionBarSherlock attaches a compatibility action bar on pre-ICS inside of the content view rather than in the Window’s decor view. Because of this, it is susceptible to more inconveniences which may cause unexpected behavior like the one you are seeing.

    If you have set the windowSoftInputMode to pan the content view when the IME is open the action bar will disappear from the screen. The simple way around this would be to use a different mode (e.g., resize) which will re-layout the content view and keep the action bar on the screen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are some HTML based games (ie bootleggers.us) that have a simple login form
Ok, i have simple scenario: have two pages: login and welcome pages. im using
I have a simple GAE app that includes a login/logout link. This app is
I have a simple web page that till now didn't need any login. It
Imagine that you have a simple site with only 2 pages: login.aspx and secret.aspx.
I have simple login box, which is centered to the middle of page (vertical
I have created a simple facebook login page at: http://bit.ly/Ims3U6 In the app settings:
Implementing a simple Login screen using JSF and Spring and Hibernate. I have written
I have a simple file-system-ed-login (not mysql) just to track number of users who
let's say I have a simple javascript like so: $(document).ready(function(){ if(login == 1) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.