9

What is the difference between Class<?> and Class<Object> in Java? AFAIK Java Erasure changes <?> to it's upper bound, which in this case would be Object anyway. So what is this for?


Call methods on fragment - every object is null

I have the following problem:

I have one Fragment, which implements a specified interface.

    @Override
public void sensorStatusChanged(double bearing, double pitch, double rotation) {
    if (radarView != null) {
        radarView.setBearing((float) bearing);
    }
    ....
}

The ParentActivity handles the Location-Listener and tries to inform the fragment that sensorData has changed.

At this part, I have the following behaviour: The method gets called, but the radarView is null. I'm 100% sure, that the radarView is not null. When I set some breakpoints into this code, the only part where the radarView is null, is inside of methods, which are called from the activitiy and not from the fragment itself.

I'm a total beginner in dealing with fragments (started today), so I think I'm doing something wrong.

How can I solve this behaviour?

Cheers

4

1 回答 1

7

不同之处在于Collection<String>它不是 , 的子类型Collection<Object>Collection<?>它可以用作可以放置任何集合的参数

于 2013-05-05T23:22:36.940 回答