Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Android SDK Samples as a Photo Gallery

Photo Gallery of Android SDK Samples.
For better understanding of what the source knows there is a gallery of images.
After clicking on the preview displays the actual size and Titlebar
You can read the path to the source file as: Graphics/AnimateDrawables see the project folder
/ApiDemos/src/com/example/android/apis/graphics/AnimateDrawable.java



396LW NO topic_id




AD

Další témata ....(Topics)


297

SurfaceView implements Runnable Android Code | surfaceview-implements-runnable-android-code



package cz.okhelp.surfview;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnTouchListener;

public class MainActivity extends Activity implements OnTouchListener {
	OurView v;
	Bitmap ball, blob;
	float x, y;
	Sprite sprite;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// setContentView(R.layout.activity_our_view);
		v = new OurView(this);
		v.setOnTouchListener(this);
		ball = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
		x = y = 0;
		setContentView(v);
	}


	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		v.pause();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		v.resume();
	}

	public class OurView extends SurfaceView implements Runnable {
		Thread t = null;
		SurfaceHolder holder;
		boolean isItOK = false;

		public OurView(Context context) {
			super(context);
			// TODO Auto-generated constructor stub
			holder = getHolder();
		}

		public void run() {
			// TODO Auto-generated method stub
			while (isItOK == true) {
				// perform canvas drawing
				if (!holder.getSurface().isValid()) {
					continue;
				}
				// sprite = new Sprite(OurView.this,blob);
				Canvas c = holder.lockCanvas();
				c.drawARGB(255, 100, 100, 10);
				c.drawBitmap(ball, x, y, null);
				// onDraw(c);
				holder.unlockCanvasAndPost(c);
			}
		}

		protected void onDraw(Canvas canvas) {
			// sprite.onDraw(canvas);
		}

		public void pause() {
			isItOK = false;
			while (true) {
				try {
					t.join();
				} catch (InterruptedException e) {
					// TODO: handle exception
					e.printStackTrace();
				}
				break;
			}// end while
		}

		public void resume() {
			isItOK = true;
			t = new Thread(this);
			t.start();
		}
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		try {
			Thread.sleep(50);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			x = event.getX();
			y = event.getY();

			break;
		case MotionEvent.ACTION_UP:
			x = event.getX();
			y = event.getY();

			break;
		case MotionEvent.ACTION_MOVE:
			x = event.getX();
			y = event.getY();

			break;
		}// end switch

		return true;
	}

}

221

android - OnClickListener must override a superclass method | android-onclicklistener-must-override-a-superclass-method


The method onClick(DialogInterface, int) of type new DialogInterface.OnClickListener(){} must override a superclass method.

Try this:
Right click on project
Select Properties
In open dialogue select Java compiler
Set Enable project specific settings
Set Compiler compliance level to 1.6

android/project-properties-eclipse.png

android/java-compiler-settings-eclipse.png