Skip to content

Commit

Permalink
弹出隐藏软键盘(如果软键盘显示)
Browse files Browse the repository at this point in the history
  • Loading branch information
baoyongzhang committed Jun 18, 2014
1 parent 354080a commit b823b31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions code/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@
android:onClick="onClick"
android:text="IOS7 Style" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>
11 changes: 11 additions & 0 deletions code/src/com/baoyz/actionsheet/ActionSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
Expand Down Expand Up @@ -74,6 +75,16 @@ public void dismiss() {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

InputMethodManager imm = (InputMethodManager) getActivity()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isActive()) {
View focusView = getActivity().getCurrentFocus();
if (focusView != null) {
imm.hideSoftInputFromWindow(focusView.getWindowToken(), 0);
}
}

mAttrs = readAttribute();

mView = createView();
Expand Down

0 comments on commit b823b31

Please sign in to comment.