Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText - keyboard doesn't appear on focus

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?

like image 461
przebar Avatar asked Mar 17 '26 00:03

przebar


1 Answers

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();
like image 138
John Miedema Avatar answered Mar 19 '26 14:03

John Miedema



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!