human
human

Reputation: 647

How to keep the button static in UI

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);

Upvotes: 1

Views: 276

Answers (4)

human
human

Reputation: 647

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.

Upvotes: 1

Monty
Monty

Reputation: 3215

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" />

Upvotes: 1

binaryKarmic
binaryKarmic

Reputation: 988

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()

Upvotes: 2

Chintan Khetiya
Chintan Khetiya

Reputation: 16152

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

Upvotes: 2

Related Questions