Java 试图从父Activity回调在库模块中创建的片段
我从stack overflow获得了调用Activity类片段中回调的代码。 我从堆栈溢出中获得以下代码Java 试图从父Activity回调在库模块中创建的片段,java,android,Java,Android,我从stack overflow获得了调用Activity类片段中回调的代码。 我从堆栈溢出中获得以下代码 fraKey fragment=(fraKey)getFragmentManager().findFragmentById(R.id.idFraKey); 我得到以下错误 inconvertable types cannot cast "android.app.fragment to com.example.mylib.keyfrag 片段代码 public class fraKey
fraKey fragment=(fraKey)getFragmentManager().findFragmentById(R.id.idFraKey);
我得到以下错误
inconvertable types cannot cast "android.app.fragment to com.example.mylib.keyfrag
片段代码
public class fraKey extends Fragment implements View.OnClickListener {
int ted=0;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_fra_key, container, false);
}
public void onViewCreated(View view, Bundle savedInstanceState) {
View temp;
temp = view.findViewById(R.id.idUpdate);
temp.setOnClickListener(this);
temp = view.findViewById(R.id.idTest);
temp.setOnClickListener(this);
}
public void onClick(View v) {
ted++;
cKeys mKeys = new cKeys();
((actMyLib)getActivity()).updateKeya(mKeys);
}
} // end class
你只需要一篇文章。这很有帮助。祝你度过愉快的一天。是凯夫拉格还是弗拉基?还有keyfrag类吗?也检查一下?