Android findViewById in service

后端 未结 1 373
臣服心动
臣服心动 2021-01-11 13:02

I am doing something like when a service get started, a custom toast notification shows up.

The custom toast view is defined in a xml file, the problem is that

相关标签:
1条回答
  • 2021-01-11 13:53

    check this post

    http://www.cloud208.com/blogica/Android+Custom+Toast+from+a+Service

    According to that post, you can use an inflater with null as the second argument:

    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.toast_layout, null);
    
    0 讨论(0)
提交回复
热议问题