如何将按钮功能添加到片段中

How can I add button function into fragments

我正在尝试创建一个学习应用程序,activity 将显示 3 个选项卡,我的问题是如何将视频视图放入选项卡中。我知道的按钮代码不起作用。关于片段时我应该使用什么语法有什么想法吗?enter image description here

做这样的事情

Public class  Tab2Vid extand Fragment implement View.OnClickListener {

    Public View onCreateView(LayoutInflater inflater, ViewGroup container
                            ,Bundle savedlnstanceState) {

    View rootView = inflater.inflate(R.layout.tab2video, container, false); 

    Button play = (Button)rootView.findViewById(R.id.btnplay);

    return rootView; 

    }

    Public void onClick(View view)( 
    switch (view.getId())
        {

            case R.id.btnplay:
              Toast.makeText(getActivity(),"Btn Play clicked", Toast.LENGTH_SHORT).show();
                break;
            default:
                return;
        }
    } 
}