Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34115
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: What does keyword 'this' refer to in the following code? |
| Date | 2016-04-12 22:00 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <nejr5l$8c9$1@dont-email.me> (permalink) |
| References | <2a655d5f-3df0-4bf2-a2bc-4b70406d7ab2@googlegroups.com> |
On Mon, 11 Apr 2016 21:44:21 -0700, cdalten wrote:
> https://developers.google.com/maps/documentation/android-api/
>
> Does 'this' refer to refer to the instance of MapPane or Activity?
It refers to the instance of MapPane as an
com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.*;
import android.app.Activity;
import android.os.Bundle;
public class MapPane extends Activity implements OnMapReadyCallback {
@Override
protected void onCreate(Bundle savedInstanceState) {
/*
* From the android.app.Activity javadoc:
* Derived classes must call through to the super class's
* implementation of this method. If they do not,
* an exception will be thrown.
*/
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
MapFragment mapFragment = (MapFragment) getFragmentManager()
.findFragmentById(R.id.map);
/*
* MapFragment.getMapAsync (OnMapReadyCallback callback)
*
* public interface OnMapReadyCallback {
* abstract void onMapReady(GoogleMap googleMap)
* }
*
* So here, "this" refers to this instance of MapPane
* as an com.google.android.gms.maps.OnMapReadyCallback
*/
mapFragment.getMapAsync(this);
}
/*
* Implementing com.google.android.gms.maps.OnMapReadyCallback
*/
@Override
public void onMapReady(GoogleMap map) {
LatLng sydney = new LatLng(-33.867, 151.206);
map.setMyLocationEnabled(true);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney, 13));
map.addMarker(new MarkerOptions()
.title("Sydney")
.snippet("The most populous city in Australia.")
.position(sydney));
}
}
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What does keyword 'this' refer to in the following code? cdalten@gmail.com - 2016-04-11 21:44 -0700
Re: What does keyword 'this' refer to in the following code? Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2016-04-12 12:16 +0300
Re: What does keyword 'this' refer to in the following code? Eric Douglas <e.d.programmer@gmail.com> - 2016-04-12 04:57 -0700
Re: What does keyword 'this' refer to in the following code? cdalten@gmail.com - 2016-04-12 08:28 -0700
Re: What does keyword 'this' refer to in the following code? Lew <lewbloch@gmail.com> - 2016-04-12 14:03 -0700
Re: What does keyword 'this' refer to in the following code? cdalten@gmail.com - 2016-04-12 18:23 -0700
Re: What does keyword 'this' refer to in the following code? Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2016-04-13 11:39 +0300
Re: What does keyword 'this' refer to in the following code? Eric Douglas <e.d.programmer@gmail.com> - 2016-04-13 05:07 -0700
Re: What does keyword 'this' refer to in the following code? Jeff Higgins <jeff@invalid.invalid> - 2016-04-12 22:00 +0000
Re: What does keyword 'this' refer to in the following code? cdalten@gmail.com - 2016-04-12 20:03 -0700
Re: What does keyword 'this' refer to in the following code? cdalten@gmail.com - 2016-04-12 21:01 -0700
Re: What does keyword 'this' refer to in the following code? Lars Enderin <lars.enderin@telia.com> - 2016-04-13 10:58 +0200
Re: What does keyword 'this' refer to in the following code? Eric Douglas <e.d.programmer@gmail.com> - 2016-04-13 05:12 -0700
csiph-web