5

I have a ListView with EditTexts as items.

I have tried setting both the android:windowSoftInputMode="adjustPan" and "adjustResize" flags in the manifest, I have also tried adding "alwaysvisible" flag and it didn't help either.

But when the keyboard hovers over the text and I start typing the edit text box is no loner visible, it only pops up the first time it gains focus.

Edit: I have tested it on 4.3 and it worked as it supposed to work, the edittext was visible all the time, but on 4.2.1/4.2.2 it doesn't work.

user1940676
  • 4,348
  • 9
  • 44
  • 73
  • 1
    Check out this solution: http://stackoverflow.com/a/19570401/1560797 . It just helped me, I had the same problem on a S2 – Theos Oct 31 '13 at 22:33

5 Answers5

7

on some specific vendors android firmwares, settings android:windowSoftInputMode for Activity tag in Manifest won't work...

possible workaround can be setting it directly from the java code, inside the onCreate() method, after setting the content view:

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

it's a long shot, but for me it worked in some cases...

Tal Kanel
  • 10,475
  • 10
  • 60
  • 98
0

I had the same problem yesterday. Solved it in this way: When user clicks an EditText, I start a timer which continuously keeps the list item visible and focused. It runs for 1.5 seconds after each click. I have a Runnable which posts itself to a handler periodically.

  • Checks if the desired list item is currently visible (scrolled to the visible part of list).
  • If it's not visible, scrolls the list to it (ListView.setSelectedItem(int position)).
  • If it's visible, focuses the EditText that belongs to the list item (View.requestFocus()).

VERY ugly solution, but does the job.

Aron Lorincz
  • 1,677
  • 3
  • 19
  • 29
0

Try to use the android default value by not setting android:windowSoftInputMode or set it to android:windowSoftInputMode:stateUnspecified. Android will choose an appropriate state if there is no one defined in your theme. I had the same problem and this was the solution.

Baschi
  • 1,128
  • 11
  • 14
0

My Problem was I have specified on my style for values-v19

<item name="android:fitsSystemWindows">false</item>

which won't allow the window to resize. So either change it to true or within the layout you want to resize add this:

<LinearLayout
android:fitsSystemWindows="true" //this line!
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

Hope it helps someone.

Coderji
  • 7,655
  • 5
  • 37
  • 51
-1

On your AndroidManifest.xml, try to add android:windowSoftInputMode="adjustPan" in the activity holding the listview.

AITAALI_ABDERRAHMANE
  • 2,499
  • 1
  • 26
  • 31
  • thats what i'm trying to solve, why it doesn't work with adjustPan or adjustResize. – user1940676 Nov 05 '13 at 10:22
  • ok, try to add yourEditText.requestFocusFromTouch() on your getView() mothode (ListAdapter) – AITAALI_ABDERRAHMANE Nov 05 '13 at 10:35
  • then, maybe you have to follow this answer, "It sounds like ListViews aren't able to handle EditTexts well. I've done some research and the consensus seems to be "don't do that." So what I've resorted to is creating a simple layout file which is a ScrollView with a LinearLayout inside. In my onCreate method, I inflate the View I was using for my list item and add it to the LinearLayout. I'm also adding the View to an ArrayList so I can save the data in each View later on" @Andrew – AITAALI_ABDERRAHMANE Nov 05 '13 at 12:18