I can\'t to get the button from fragment, what\'s wrong? Recieve a uncaught exception - nullpointerexception; Button can\'t be found.
Early all will be find, but aft
You are trying to search inside Activity
's layout, and your widgets are inside a Fragment
's layout.
Put your logic inside your PlaceHolderFragment
class:
public static class PlaceholderFragment extends Fragment implements OnClickListener {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
mplayer = new MediaPlayer();
rgroup = (RadioGroup) rootView.findViewById(R.id.radioGroup1);
play = (Button) rootView.findViewById(R.id.play);
pause = (Button) rootView.findViewById(R.id.pause);
play.setOnClickListener(this);
pause.setOnClickListener(this);
return rootView;
}
@Override
public void onClick(View v) {
}
}
P.S. Салам алейкум =)