Android - Cheat Sheet: Unterschied zwischen den Versionen
Aus Wikizone
| Zeile 57: | Zeile 57: | ||
https://developers.google.com/maps/documentation/android/?hl=de | https://developers.google.com/maps/documentation/android/?hl=de | ||
http://ddewaele.github.io/GoogleMapsV2WithActionBarSherlock/part1 | http://ddewaele.github.io/GoogleMapsV2WithActionBarSherlock/part1 | ||
| + | === Voraussetzungen === | ||
| + | * Google Play Services SDK muß installiert sein (SDK Manager) | ||
| + | * In Eclipse muß folgendes Projekt importiert werden: myadtfolder/sdk/extras/google/google_play_services/libproject/google-play-services_lib damit die Packages zur Verfügung stehen. | ||
| + | * Man braucht eine gültige Signierung für die App | ||
| − | |||
Manifest (innerhalb application tag): | Manifest (innerhalb application tag): | ||
<uses-library android:name="com.google.android.maps" /> | <uses-library android:name="com.google.android.maps" /> | ||
Activity Klasse | Activity Klasse | ||
extends MapActivity | extends MapActivity | ||
Version vom 11. Oktober 2013, 11:28 Uhr
Hier gibt es nur Code Schnipsel zum Kopieren ohne Erklärung
Neue Activity
MyNameActivity.java // Class activity_my_name.xml // Layout File AndroidManifest.xml strings.xml
Activity Class
package de.webmynet.android.myappname;
import android.app.Activity;
import android.os.Bundle;
public class MyNameActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_name);
}
}
Buttons verdrahten
import android.widget.Button;
public class MyNameActivity extends Activity implements OnClickListener {
Button b1,b2;
...
b1 = (Button)findViewById(R.id.b1);
b2 = (Button)findViewById(R.id.b2);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
...
@Override
public void onClick(View v) {
int id = v.getId();
Intent i = null;
switch (id){
case R.id.b1:
i = new Intent(this,OtherNameActivity.class);
break;
case R.id.b2:
i = new Intent("de.webmynet.appname.OTHERNAME");//Variant with Manifest Activity Name
break;
default:
break;
}
startActivity(i);
}
MapView Activity
https://developers.google.com/maps/documentation/android/?hl=de http://ddewaele.github.io/GoogleMapsV2WithActionBarSherlock/part1
Voraussetzungen
- Google Play Services SDK muß installiert sein (SDK Manager)
- In Eclipse muß folgendes Projekt importiert werden: myadtfolder/sdk/extras/google/google_play_services/libproject/google-play-services_lib damit die Packages zur Verfügung stehen.
- Man braucht eine gültige Signierung für die App
Manifest (innerhalb application tag):
<uses-library android:name="com.google.android.maps" />
Activity Klasse
extends MapActivity