在 fragment 里面调用 findViewById

来源:互联网 发布:百度指数 数据导出 编辑:程序博客网 时间:2024/05/18 02:17
在 fragment 里面调用 findViewById

public class CompanyListFragment  extends Fragment {

  private Activity activity;
    private ListView companyListView;

  @Override
  public View onCreateView(LayoutInflater infalter, ViewGroup container, Bundle savedInstanceState) {
    View view = infalter.inflate(R.layout.companylist_for_sport, container, false);
    companyListView = (ListView)view.findViewById(R.id.companyListView);
    return view;
  }

}

注意1:  是在 onCreateView 中

注意2:  是 view.findViewById 而不是 activity.findViewById

0 0
原创粉丝点击