在Fragment中使用finviewbyid方法

在fragment中无法直接使用findviewbyid的方法,需要先得到fragment的对象
 
 
View view = inflater.inflate(R.layout. fragment_home , container , false) ;

得到view对象后才能使用

myView = (MyView) view.findViewById(R.id.activity_man_myview);

猜你喜欢

转载自blog.csdn.net/ct_ts/article/details/79682299