 <p>Also you can not use getView() inside onCreateView because the view you are accessing has not been created yet. So you should do it like this:</p> <p>View view = inflater.inflate(R.layout.dpsfrag, container, false);</p> <p>TextView tv= (TextView) view.findViewById(R.id.textView1); </p> <p>tv.setText("hello");</p> <p>return view;</p>