我正在尝试创建一个带有可滚动文本的片段。我有以下使用以下两种方法扩展 Fragment 的类。我收到一个错误“对于 exampleFragmentText 类型的方法 findViewbyID(int) 是未定义的”,对于 exampleFragmentText 类型的方法“stSelected(boolean) 是未定义的”我应该怎么做?
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.textview_main, container, false); //just return the view ;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
//here you can initialise your variables,listeners,e.t.c ;
super.onActivityCreated(savedInstanceState);
TextView textView = (TextView) findViewbyID(R.id.myText);
textView.stSelected(true);
// addListenerOnButton();
}
protected View findViewById(int id)
{
return getView().findViewById(id);
}