android - How to get focusable in a windowmanager view -


i use windowmanager create view , add view screen,but cannot view focusable.i think set windowmanager.layoutparams correct.

    @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.fragment_main);     pushview = layoutinflater.from(getapplicationcontext()).inflate(             r.layout.push, null);      btn = (button) findviewbyid(r.id.btn);     cancelbtn = (button) pushview.findviewbyid(r.id.cancelbtn);     windowmanager = getwindowmanager();     handler = new myhandler();      pushview.setonclicklistener(new onclicklistener() {          @override         public void onclick(view arg0) {             system.out.println("onclick");             windowmanager.removeview(pushview);         }     });       btn.setonclicklistener(new onclicklistener() {          @override         public void onclick(view arg0) {             windowmanager.layoutparams params = new windowmanager.layoutparams(                     windowmanager.layoutparams.match_parent,                      windowmanager.layoutparams.wrap_content,                      windowmanager.layoutparams.type_system_overlay,                      windowmanager.layoutparams.flag_layout_in_screen |                      windowmanager.layoutparams.flag_fullscreen,                      pixelformat.translucent);             params.gravity = gravity.top | gravity.left;             params.y = 0;             params.x = 0;              windowmanager.addview(pushview, params);              new timer().schedule(new timertask() {                  @override                 public void run() {                     message msg = handler.obtainmessage();                     handler.sendemptymessage(0x123);                 }             }, 5000);          }     });  } 

i want pushview'focusable handle view's event.this problem has troubled me long time.who can me...

you need remove flag_not_focusable flag:

params.flags = params.flags & ~windowmanager.layoutparams.flag_not_focusable; 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -