1

1) I have this UI where the button at the bottom of the screen must be static when the soft keyboard appears. i.e now it comes as

BEFORE

before choosing DR

AFTER

After choosing DR

2) while on soft keyboard when I press enter the next edit text field must come into focus . (i.e) while on K1 and I press enter the focus must shift to K2 and must be visible.

EDIT This is how i get edit text field

dr_e=(EditText)findViewById(R.id.dr_editText);
            InputMethodManager imm = (InputMethodManager)getSystemService(
                      Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(dr_e.getWindowToken(), 0);
            k1_e=(EditText)findViewById(R.id.k1_editText);
            k2_e=(EditText)findViewById(R.id.k2_editText);
            al_e=(EditText)findViewById(R.id.al_editText);
            alconst_e=(EditText)findViewById(R.id.al_const_editText);
human
  • 637
  • 4
  • 15
  • 41

4 Answers4

2

To show Soft Keyboard for EditText:

EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

To hide Soft Keyboard for EditText:

InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);

See more

Refer this links: http://www.androidpeople.com/android-hide-virtual-keyboard-through-code/ , Close/hide the Android Soft Keyboard

Community
  • 1
  • 1
Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85
2

For defining which view should get next focus(say next focus to the view below) try the next

android:nextFocusDown. For the complete guide search for the section "Focus Handling"

Now the next part, at the last edit text i.e the one before the button you will want the "enter" button on the soft keyboard to directly act as the Result button. For that set onEditorActionListener and override the onEditorAction(TextView v, int actionId, KeyEvent event) method. check if the actionId is actionSend and programmatically click your "Result" button.

For this your last edittext should have the property android:imeOptions="actionSend" and for programmatically clicking the button use Button.performCLick()

binaryKarmic
  • 978
  • 7
  • 22
  • the thing is i am able to focus down but due to RESULT button appearing above soft keyboard the focused edittext field is not visible unless it is scrolled – human Mar 29 '13 at 07:03
  • 1
    two options : (1)either add android:windowSoftInputMode="adjustPan" so that the edittext which is in focus will come just above the soft keyboard. (2) have your screen layout inside a Scrollview and let the user scroll up in case the edittext hides. – binaryKarmic Mar 29 '13 at 07:11
  • but still the result button scrolls up :( i dont want result button to scroll up while soft keyboard comes up – human Mar 29 '13 at 07:29
  • Why you want that? Are you sure your requirement is right? But still if you do not want that remove the android:windowSoftInputMode property and just keep the scrollview – binaryKarmic Mar 29 '13 at 08:35
1

Can You check this in your manifest file

android:windowSoftInputMode="adjustUnspecified"; 

I ll give you adjustable size on window and related values.

update:-

android:imeOptions="actionNext";

try this in your xml ,where is your first edittext there.like this

 <EditText
    android:id="@+id/et"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:imeOptions="actionNext" />
Monty
  • 3,205
  • 8
  • 36
  • 61
1

The main reason why the next edit text field focussed, was not able to be viewed was because of the result button popping up whenever the soft keyboard appears. to that use

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

in onCreate() method of the class.

human
  • 637
  • 4
  • 15
  • 41
  • this is as same as android:windowSoftInputMode="adjustPan" to the activity entry in androidmanifext.xml as i had said in the comment. Anyways do accept the answer if ur query is solved. – binaryKarmic Mar 29 '13 at 13:20
  • @jagz87 ya but directly i cant accept your answer but upvoted that particular comment. – human Mar 31 '13 at 13:04