Focus EditText and ListView in Android

I have within my app, a search functionality. The search box is a basic EditText box with an OnTextChangeListener attached. Below the search box, I have a ListView which displays the results of the search query. Results are displayed as the user begins to type in the search box.

The problem I'm faced with is that the keyboard covers my ListView hence the user cannot see the search results unless the keyboard is hidden. This happens because the keyboard will appear just below the EditText box.

One possible solution is to place the search box below the ListView but is it not aesthetically feasible. The other is to encapsulate both entities with a ViewGroup in an attempt to have the keyboard push up beneath, hence the ListView and the EditText box are visible. Does anyone have a better solution?


I think you can take scrollView and in the scrollView,put your editText and listView just like:

<ScrollView . . .>
    <EditText . . . />
    <ListView . . . />
</ScrollView>

Hope it will help you with your problem.


My solution:

Not the greatest but I simply moved the PageLayout up by adjusting the Y co-ordinate.

链接地址: http://www.djcxy.com/p/24222.html

上一篇: 将焦点设置在EditText上

下一篇: 在Android中关注EditText和ListView