Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:background="@drawable/login_bg">
  6. ...
  7.  
  8. <FrameLayout
  9. android:id="@+id/fragment_container"
  10. android:layout_width="match_parent"
  11. android:layout_height="match_parent"/>
  12.  
  13. ...
  14.  
  15. </RelativeLayout>
  16.  
  17. <activity
  18. android:name="com.demo.LoginActivity"
  19. android:configChanges="orientation|keyboardHidden"
  20. android:launchMode="singleTop"
  21. android:screenOrientation="portrait"
  22. android:theme="@style/activityTheme" />
  23.  
  24. private void startFragment(BaseFragment fragment, String tag) {
  25. FragmentManager fragmentManager = getSupportFragmentManager();
  26. FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  27. fragmentTransaction.add(R.id.fragment_container, fragment);
  28. fragmentTransaction.addToBackStack(tag);
  29. fragmentTransaction.commitAllowingStateLoss();
  30. }
  31.  
  32. <?xml version="1.0" encoding="utf-8"?>
  33. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  34. android:layout_width="match_parent"
  35. android:layout_height="match_parent"
  36. android:background="@color/common_background_color_white"
  37. android:orientation="vertical"
  38. android:clickable="true"
  39. android:paddingLeft="@dimen/email_common_padding_horizontal"
  40. android:paddingRight="@dimen/email_common_padding_horizontal">
  41.  
  42. ...
  43.  
  44. <com.example.widget.LineEditView
  45. android:id="@+id/login_email_input"
  46. style="@style/BaseEditText.LoginEditText"
  47. android:layout_width="match_parent"
  48. android:layout_height="wrap_content"
  49. android:focusable="true"
  50. />
  51.  
  52. ...
  53.  
  54. </LinearLayout>
  55.  
  56. <?xml version="1.0" encoding="utf-8"?>
  57. <RelativeLayout
  58. xmlns:android="http://schemas.android.com/apk/res/android"
  59. android:id="@+id/input"
  60. android:layout_width="match_parent"
  61. android:layout_height="wrap_content">
  62.  
  63. <EditText
  64. android:id="@+id/edit"
  65. android:layout_width="match_parent"
  66. android:layout_height="wrap_content"
  67. android:focusable="true"
  68. android:gravity="start|center_vertical"
  69. android:background="@android:color/transparent"
  70. android:textColor="@color/common_text_color_black"
  71. android:maxLines="1"
  72. android:textCursorDrawable="@drawable/common_cursor_background_orange"
  73. android:textSize="@dimen/email_fields_text_size"
  74. android:paddingBottom="@dimen/email_fields_text_padding_bottom"/>
  75.  
  76. <View
  77. android:id="@+id/underline"
  78. android:layout_below="@id/edit"
  79. android:layout_width="match_parent"
  80. android:layout_height="2px"/>
  81. </RelativeLayout>
  82.  
  83. @Override
  84. public View onCreateView(LayoutInflater inflater, ViewGroup container) {
  85. mEditText = (EditText) rootView.findViewById(R.id.edit);
  86. mEditText.requestFocus();
  87. mEditText.setFocusable(true);
  88. }
  89.  
  90. @Override
  91. public void onResume() {
  92. mEditText.postDelayed(mShowSoftInputRunnable, 400);
  93. super.onResume();
  94. }
  95.  
  96. private Runnable mShowSoftInputRunnable = new Runnable() {
  97. @Override
  98. public void run() {
  99. FragmentActivity activity = getActivity();
  100. if (activity == null)
  101. return;
  102.  
  103. InputMethodManager input = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
  104. input.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT);
  105. }
  106. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement