Android - Cheat Sheet: Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
Zeile 53: Zeile 53:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
== MapView Activity ==
 +
https://developers.google.com/maps/documentation/android/?hl=de
 +
http://ddewaele.github.io/GoogleMapsV2WithActionBarSherlock/part1
 +
 +
* Google Play Services SDK configured within Eclipse (SDK Manager)
 +
Manifest (innerhalb application tag):
 +
<uses-library android:name="com.google.android.maps" />
 +
Activity Klasse
 +
extends MapActivity

Version vom 11. Oktober 2013, 10:37 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
  • Google Play Services SDK configured within Eclipse (SDK Manager)

Manifest (innerhalb application tag):

<uses-library android:name="com.google.android.maps" />

Activity Klasse

extends MapActivity