首页 > 移动平台 > 详细

android getActivity.findViewById获取ListView 返回NULL

时间:2015-05-27 11:53:40      阅读:295      评论:0      收藏:0      [点我收藏+]

在控件ID正确的情况下,检查是否在实例化布局文件之后,获取LISTVIEW,

先inflate找layout下布局文件,并实例化后才能获得Listview的ID

demo:

public class FragmentPage extends Fragment {
View view = null;

    @Override
    @SuppressLint("HandlerLeak")
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

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

               

            // @此处获取使用view.findViewById(list的ID);

      

       //最后返回加载后的布局文件
        return view;

    }

}

android getActivity.findViewById获取ListView 返回NULL

原文:http://www.cnblogs.com/umlzhang/p/4532756.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!