Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 6e42d05

Browse files
author
evgenii
committed
Added an auto-showing of the soft keyboard on appearing of AddRecord fragments.
1 parent 0a68771 commit 6e42d05

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

app/src/main/java/com/blogspot/e_kanivets/moneytracker/fragment/AddExpenseFragment.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.blogspot.e_kanivets.moneytracker.fragment;
22

33
import android.app.Activity;
4+
import android.content.Context;
45
import android.os.Bundle;
56
import android.support.v4.app.Fragment;
67
import android.support.v7.app.ActionBar;
@@ -11,6 +12,8 @@
1112
import android.view.MenuItem;
1213
import android.view.View;
1314
import android.view.ViewGroup;
15+
import android.view.ViewTreeObserver;
16+
import android.view.inputmethod.InputMethodManager;
1417
import android.widget.ArrayAdapter;
1518
import android.widget.EditText;
1619
import android.widget.Spinner;
@@ -169,6 +172,11 @@ private void initViews(final View rootView) {
169172
}
170173
}
171174
}
175+
176+
/* Show keyboard and set focus on etTitle */
177+
InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
178+
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
179+
etTitle.requestFocus();
172180
}
173181
}
174182

app/src/main/java/com/blogspot/e_kanivets/moneytracker/fragment/AddIncomeFragment.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ private void initViews(final View rootView) {
170170
}
171171
}
172172
}
173+
174+
/* Show keyboard and set focus on etTitle */
175+
InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
176+
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
177+
etTitle.requestFocus();
173178
}
174179
}
175180

0 commit comments

Comments
 (0)