开发者

Service and view

开发者 https://www.devze.com 2023-02-03 02:03 出处:网络
Can i get a view by calling findIdBy(R.id.x) in a Service? th开发者_如何学PythonanksShort answer: No.

Can i get a view by calling findIdBy(R.id.x) in a Service? th开发者_如何学Pythonanks


Short answer: No.

Should you attempt it: No.

Is it good practice: No.

Would it ever be useful to do this: No.

If you want to do this are you doing something wrong: Yes

Is it possible, in a convoluted way that goes against everything that you should do in an Android idiomatic program: Yes.


You can inflate views defined in an XML file using

getLayoutInflater().inflate(...)

See the SoftKeyboard example for why and how to do this in a service context

0

精彩评论

暂无评论...
验证码 换一张
取 消