EditText - keyboard doesn't appear on focus

17,744

See this answer. It solved the same problem for me:

Keyboard not shown when i click on edittextview in android?

and try this code

mEditText.clearFocus();
Share:
17,744
przebar
Author by

przebar

Updated on June 04, 2022

Comments

  • przebar
    przebar almost 2 years

    I have this annoying problem. My app has 2 activities (tabs) Activity1:listview, Activity2:editText+listview. App starts with Tab1(Activity1). When i open 2nd Activity (with edittext), no matter if EditText is selected or not (programmable), when i click on EditText, nothing happens (softKeyboard should appear). Only solution is to change activity (click on Tab1 widget) and return to activity 2 - after this tab swap, keyboard works fine.

    Part of XML layout with edittext:

        <EditText
        android:hint="Wyszukaj..."
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:inputType="textAutoComplete|text"
        android:singleLine="true" 
        android:focusable="true"
        android:focusableInTouchMode="true"
    >
    

    and here is 2 overrided method from Activity2

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tab2);
    
        this.db = DataBase.getInstance();
        this.ds = DataSource.getInstance();
        this.prepareListView();
    }
    
    @Override
    protected void onResume() {
        super.onResume();
        this.doubleBackToExitPressedOnce = false;
    }
    private void prepareListView() {
        sbal = this.db.getAllStops();
        adapter = new StopListAdapter(this, sbal);
    
        lv = (ListView) findViewById(R.id.tab2list);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(onClick);
        EditText et = (EditText) findViewById(R.id.editText1);
        et.addTextChangedListener(changeWatcher);
        registerForContextMenu(lv);
    }
    

    Do you have any ideas, how XMLcode and activity code should look like in this case?

  • przebar
    przebar about 12 years
    the same, removing those lines doesn't helps ;/
  • przebar
    przebar about 12 years
    sorry, still nothing happens;/
  • Prashant Mishra
    Prashant Mishra about 12 years
    android:windowSoftInputMode="stateAlwaysHidden|adjustResize" > try by adding this in your activity tag in manifest.xml
  • przebar
    przebar about 12 years
    i tried add this to activity2 and/or main activity - no effectts