Android-View:写在main activity.Jav

2017-10-30  本文已影响0人  Toluv

  在使用findviewbyid控件的时候,其中的id是需要指定一个layout的,不然就会默认用main activity的layout。popupwindows控件也是一个道理

使用父view让id有一个指向,不让就会有空指针。

代码:LayoutInflater inflater=(Layout Inflater)get System Service(context. LAYOUT_INFLATER_SERVICE);

View view = inflater. inflate(R.layout. (父layout),null);

上一篇 下一篇

猜你喜欢

热点阅读