Android activity group with taboo, keyboard not showing

I have a taboo and for each tab I have an activity group.

When the application starts, and I click on editText, the keyboard exits. When I start a child activity, and then return to the main activity, the keyboard no longer exits.

My code to run subactivity

Intent i = new Intent(this, ShowAddFoodToSelection.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

View view = ActivityGroupMeal.group.getLocalActivityManager().startActivity(DataParser.activityIDMeal, i).getDecorView();

ActivityGroupMeal.group.setContentView(view);

my code to return to the main activity

ActivityGroupMeal.group.back();

And the back code in the workgroup:

public void back() {
        try {
            // if we set history.size() > 0 and we press back key on home
            // activity
            // and then on another activity we wont get back!
            if (history.size() > 1) {
                history.remove(history.size() - 1);
                // call the super.setContent view! so set the real view
                super.setContentView(history.get(history.size() - 1));
            } else {

            }
        } catch (Exception e) {
            if (history.size() >= 0)
                super.setContentView(history.get(0));
        }
    }

i set onClickListenerin editTextusing the following code:

private void keyboardShow() {
        InputMethodManager inputManager = (InputMethodManager) ActivityGroupMeal.group.getSystemService(Context.INPUT_METHOD_SERVICE);

        boolean test = inputManager.showSoftInput(editTextSearch, InputMethodManager.SHOW_IMPLICIT);

        Toast.makeText(this, "show keyboard " + test, Toast.LENGTH_SHORT).show();
    }

The first time true is returned and the time I return from childactivity, it returns false.

When I click on another tab and then back to the first tab and then click on editText, it returns true again.

: , onClickListener editTextbox,

InputMethodManager inputManager = (InputMethodManager) ActivityGroupMeal.group
                .getSystemService(Context.INPUT_METHOD_SERVICE);

        // show keyboard , when it fails first switch tab and then try again
        if (!inputManager.showSoftInput(null, InputMethodManager.SHOW_FORCED)) {
            // switch from tab and back
            // the keyboard wont show if we dont do this
            ShowHomeTab parentActivity;
            parentActivity = (ShowHomeTab) this.getParent().getParent();
            parentActivity.goToTab(DataParser.activityIDTracking);
            parentActivity.goToTab(DataParser.activityIDShowFoodList);

            inputManager.showSoftInput(null, InputMethodManager.SHOW_FORCED);
        }

childactivity, , =/

- ?

+3
2

, Activity Group,

YOUR_EDIT_TEXT.setOnEditorActionListener(new OnEditorActionListener() {

            public boolean onEditorAction(TextView v, int actionId,
                    KeyEvent event) {
                if (event != null&& (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                    InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                    in.hideSoftInputFromWindow(searchName
                            .getApplicationWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
                }
                return false;
            }
        });

. .

+4

requestFocus /> EditText, ..

<EditText android:id="@+id/edit_text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="text" >
        <requestFocus />
</EditText>

, back(), requestFocus()

+1

All Articles