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.

Draw Rect Android basic example

drawRect(), Paint, setStroke(), setStyle(), Canvas example source code.

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}

		@Override
		protected void onDraw(Canvas canvas) {

			canvas.drawColor(Color.CYAN);
			Paint p = new Paint();
			// smooths
			p.setAntiAlias(true);
			p.setColor(Color.RED);
			p.setStyle(Paint.Style.STROKE); 
			p.setStrokeWidth(4.5f);
			// opacity
			//p.setAlpha(0x80); //
//drawRect (float left, float top, float right, float bottom, Paint paint) 
			canvas.drawRect(10, 10, 30, 30, p);
		}

	}
}

396LW NO topic_id




AD

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


101

Start an new Activity Intent with a parameter Android example | start-an-activity-with-a-parameter-android-example


putString(), putBoolean(), putInt() etc.¨
How we can start an activity programmatically.

// MainActivity.java
//  myButton.setOnClickListener
Intent binary = new Intent(getApplicationContext(),Calculate.class);
	Bundle b = new Bundle();
	b.putString("prvni_label", "Decimal");
	b.putString("druhy_label", "Binary");
	b.putString("mode", "binary_to_decimal");
        binary.putExtras(b);
	startActivityForResult(binary, 0);
						
// in Calculate.java onCreate

   TextView mTextView1 = (TextView)findViewById(R.id.textView1);
   TextView mTextView2 = (TextView)findViewById(R.id.textView2);    
     Bundle _bundle = getIntent().getExtras();
		mTextView1.setText(_bundle.getString("prvni_label"));
		mTextView2.setText(_bundle.getString("druhy_label"));




//.................. HOW OPEN START NEW ACTIVITY WITHOUT A PARAMETER .........................

startActivity(new Intent(ThisActivity.this, NewActivity.class));
142

Create bitmap and draw text into bitmap Android example | create-bitmap-and-draw-text-into-bitmap-android-example



public class ApokusActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.GREEN);
            
           Bitmap b = Bitmap.createBitmap(200, 200, Bitmap.Config.ALPHA_8);
           Canvas c = new Canvas(b);
           c.drawRect(0, 0, 200, 200, paint);
           
           paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
           paint.setTextSize(40);
           paint.setTextScaleX(1.f);
           paint.setAlpha(0);
           paint.setAntiAlias(true);
           c.drawText("Your text", 30, 40, paint);
           paint.setColor(Color.RED);
           
           canvas.drawBitmap(b, 10,10, paint);
		}

	}
}


android/draw-text-into-bitmap-android.png

100

How evaluate any expression in Eclipse debugger editor Android example | how-evaluate-any-expression-in-eclipse-debugger-editor-android-example


Tutorial by pictures how evaluate a variable in Eclipse debugger window.

1.) Open Debug perspective in Eclipse and to start debugging a Activity.
android/eclipse-debug-perspective.png


2.) Open Display window from menu Window->Show view->Display

android/eclipse-show-view-display.png

3.) Set breakpoint where you need to evaluate a variable.

android/eclipse-toggle-breakpoint.png

4.) Debug the Activity to breakpoint.

android/eclipse-debugger-breakpoint.png


5.) Into the Display window type code for evaluate your variable and execute code.

android/eclipse-type-evaluate-code-to-display-window.png


6.) Check if change of value a variable

android/eclipse-evaluate-a-variable.png

186

NoClassDefFoundError: com.google.ads.AdView ADT 17 | noclassdeffounderror-com-google-ads-adview-adt-17


Eclipse update ADT 17 Android Emulator error: E/AndroidRuntime(370): java.lang.NoClassDefFoundError: com.google.ads.AdView

Solution:
-right click on the project in project tree and select Project properties
-select Java Build Path
-select TAB Order and Export
-check GoogleAdMobAdsSdk-4.0.4.jar (or your version SDK)
-press OK
-clean project by menu Project -> Clean
-rebuild project (Project - Build Automatically)

How add GoogleAdMobAdsSdk....jar to project:
-right click on the project in project tree and select Project properties
-select Java Build Path
-select TAB Libraries
-press the button Add External JARs...
-select your version GoogleAdMobAdsSdkXXX.jar what you can using
-OK
-OK
-clean project
-rebuild project


android/menu-project-properties-eclipse.png
android/order-and-export-eclipse.png
android/eclipse-add-jar-library-to-project.png
120

Statistics usability of mobile phones with Android – October 2011 | statistics-usability-of-mobile-phones-with-android-%e2%80%93-october-2011


Table of usability phones with Android: (Our software)












October 2011 September 2011












Samsung Galaxy S2 10,90%
Samsung Galaxy S 8,10%
Samsung Galaxy Tab 7,00%
Samsung Galaxy Mini 6,20%
HTC Desire HD 4,10%
Samsung Galaxy Ace 4,10%
Samsung Galaxy S 4,00%
Samsung Galaxy Fit 3,30%
HTC Wildfire 3,20%
SEMC Xperia X10 2,20%

























Samsung Galaxy S213.8%
Samsung Galaxy S8.5%
Samsung Galaxy Tab7.4%
Samsung Galaxy Mini5.4%
Samsung Galaxy S4.0%
HTC Desire HD3.8%
Samsung Galaxy Ace3.8%
HTC Wildfire3.2%
Samsung Galaxy Fit3.1%
SEMC Xperia X102.1%



Graph of usability Smartphone with Android - October 2011:
android/phones-usability-wiht-android-october-2011.png


Samsung Galaxy S2 vs iPhone4 - video


Samsung Galaxy S2 vs iPhone4 - browsing, gaming, apps, performance, browser, fast, against, navigation, Sygic, apk, Android, iOS