android - Keyboard Issue With Framelayout -
i've edittext on layout framelayout, problem when finish entering data in edittext press button on mobile hide keypad, keeps showing shadow of keypad until press on activity.
how can solve problem.
here happen after press button hide keypad, have press again on activity make black shadow disappears.(check black shadow in bottom)
androidmanifest.xml
<activity android:name="com.example.mainactivity" android:configchanges="keyboardhidden|orientation|screensize|screenlayout" android:label="@string/app_name" android:screenorientation="portrait" android:windowsoftinputmode="adjustpan" > </activity>
activty_main.xml
<com.example.layout.mainlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <framelayout android:id="@+id/activity_main_content_fragment" android:layout_width="match_parent" android:layout_height="match_parent"> </framelayout></com.example.layout.mainlayout>
updated:- mainactivity.java
public class mainactivity extends fragmentactivity { // mainlayout hold both sliding menu , our main content // main content holds our fragment respectively mainlayout mainlayout; // listview menu private listview lvmenu; private string[] lvmenuitems; // menu button textview btmenu; // title according fragment textview tvtitle; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // inflate mainlayout mainlayout = (mainlayout)this.getlayoutinflater().inflate(r.layout.activity_main, null); setcontentview(mainlayout); lvmenuitems = getresources().getstringarray(r.array.menu_items); lvmenu = (listview) findviewbyid(r.id.activity_main_menu_listview); lvmenu.setadapter(new arrayadapter<string>(this, android.r.layout.simple_list_item_1, lvmenuitems)); lvmenu.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { onmenuitemclick(parent, view, position, id); } }); // menu button btmenu = (textview) findviewbyid(r.id.activity_main_content_button_menu); btmenu.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // show/hide menu togglemenu(v); } }); // title textview tvtitle = (textview) findviewbyid(r.id.activity_main_content_title); // add fragmentmain initial fragment fragmentmanager fm = mainactivity.this.getsupportfragmentmanager(); fragmenttransaction ft = fm.begintransaction(); fragmenthome fragment = new fragmenthome(); ft.add(r.id.activity_main_content_fragment, fragment); ft.commit(); } public void togglemenu(view v){ mainlayout.togglemenu(); } // perform action when menu item clicked private void onmenuitemclick(adapterview<?> parent, view view, int position, long id) { string selecteditem = lvmenuitems[position]; string currentitem = tvtitle.gettext().tostring(); // nothing if selecteditem currentitem if(selecteditem.compareto(currentitem) == 0) { mainlayout.togglemenu(); return; } fragmentmanager fm = mainactivity.this.getsupportfragmentmanager(); fragmenttransaction ft = fm.begintransaction(); fragment fragment = null; string[] menu = getresources().getstringarray(r.array.menu_items); if(selecteditem.compareto(menu[0]) == 0) { fragment = new fragmenthome(); } else if(selecteditem.compareto(menu[1]) == 0) { fragment = new fragmentsettings(); } if(fragment != null) { // replace current fragment new 1 ft.replace(r.id.activity_main_content_fragment, fragment); ft.commit(); // set title accordingly tvtitle.settext(selecteditem); } // hide menu anyway mainlayout.togglemenu(); } @override public void onbackpressed() { if (mainlayout.ismenushown()) { mainlayout.togglemenu(); } else { super.onbackpressed(); } } @override public void onconfigurationchanged(configuration config){ super.onconfigurationchanged(config); setrequestedorientation(activityinfo.screen_orientation_portrait); }
}
finally did it. had add on fragment
inputmethodmanager imm = (inputmethodmanager) getactivity().getsystemservice(context.input_method_service); imm.hidesoftinputfromwindow(myedittext.getwindowtoken(), 0);
Comments
Post a Comment