Fragment cast işlemi hatası
package com.milcanx.fragmentlerarasiveri;
import android.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class FragmentBOSS extends AppCompatActivity implements Communicator {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragment_boss);
}
@Override
public void respond(String data) {
FragmentManager manager = getFragmentManager();
FragmentB fmB = (FragmentB) manager.findFragmentById(R.id.fragmentBinLayout);
fmB.ChangeText(data);
}
}
Burada FragmentB fmB = (FragmentB) manager.findFragmentById(R.id.fragmentBinLayout); işleminde hata alıyorum
Hata şu
06-17 08:52:18.044 10128-10128/com.milcanx.test E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.milcanx.test, PID: 10128
java.lang.ClassCastException: com.milcanx.fragmentlerarasiveri.FragmentA cannot be cast to com.milcanx.fragmentlerarasiveri.FragmentB
at com.milcanx.fragmentlerarasiveri.FragmentBOSS.respond(FragmentBOSS.java:20)
at com.milcanx.fragmentlerarasiveri.FragmentA.onClick(FragmentA.java:32)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)