Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] java – How to prevent layout from automatically opening keyboard?

Posted on November 14, 2022

Solution 1 :

There are a few things you can do for example:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

Or

<activity
        ...
        android_windowSoftInputMode="stateHidden|adjustPan"
        ...
        >

Another thing to try

<style name="MyTheme" parent="Theme">
    <item name="android:windowSoftInputMode">stateHidden</item>
</style>

<application android_theme="@style/MyTheme">

Add these two properties to your parent layout (ex: Linear Layout, Relative Layout)

android:focusable="false"
android_focusableInTouchMode="false" 

Solution 2 :

Because your widget(com.pchmn.materialchips.ChipsInput) is the first widget in Activity, there is a focus on this widget.

To solve this problem, you need to turn off the focus so that the keyboard does not open when the activity starts

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editTextField.getWindowToken(), 0);

Manifest in tag current activity:

android:windowSoftInputMode="stateHidden"

Problem :

I’m using MaterialChipsInput. I have the following code:

<LinearLayout
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
    android_layout_below="@id/tile_divider2"
    android_orientation="vertical">

    <TextView
        android_id="@+id/text1"
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_text="@string/header" />

    <com.pchmn.materialchips.ChipsInput
        android_id="@+id/chips1"
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        app_chip_backgroundColor="@color/primaryColor"
        app_chip_deletable="true"
        app_chip_hasAvatarIcon="false"
        app_chip_labelColor="@color/whiteColor"
        app_showChipDetailed="false"
        app_hint="@string/hint" />

</LinearLayout>

And the java code is:

        chipsInput = (ChipsInput) findViewById(R.id.chips1);
        chipsInput.addChipsListener(new ChipsInput.ChipsListener() {
            @Override
            public void onChipAdded(ChipInterface chip, int newSize) {}

            @Override
            public void onChipRemoved(ChipInterface chip, int newSize) {}

            @Override
            public void onTextChanged(CharSequence text) {
                if (text != null && text.toString().contains(" ") && text.toString().length() > 1) {
                    final String tag = StringUtils.capitalizeFully(text.toString().replaceAll(" ","").trim());
                    if (!(tag.isEmpty())) {
                        chipsInput.addChip(tag, null);
                    }
                }
            }
        });

For some reason, when I move to the activity and it loads the layout with that component, it automatically opens a keyboard on the ChipsInput. What could be the reason and how to prevent it?

READ  [ANSWERED] kotlin - How to use MultiDetector in android ML kit
Powered by Inline Related Posts

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress