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 drawARGB() Android basic example


AD MOB


public class MainActivity 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) {
			//drawARGB (int a, int r, int g, int b)
//			a  alpha component (0..255) of the color to draw onto the canvas 
//			r  red component (0..255) 
//			g  green component (0..255)  
//			b  blue component (0..255)  

			canvas.drawARGB(255, 0, 255, 10); 
		}

	}
}



397LW NO topic_id




AD

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


213

Round number float - double to int - long Java example | round-number-float-to-int-java-example



int nf = Math.round(5.789f);
System.out.print(nf); // 6

float f = 28.611f; 
int n3 = Math.round(f);
System.out.println(n3); // 29

double d = 1234.56;
long lon = Math.round(d);
System.out.println(lon); // 1235

int diff = 90 - 40;
// float fDeleni = diff / 10; // error code
float fDeleni = (float)diff / 10.f; // ok
int nRound = Math.round(fDeleni);


// Caution:
int n2 = (int) 8.999f;
System.out.println(n2); // 8


197

Nejlepší mobil s Androidem - jak nakupovat | nejlepsi-mobil-s-androidem-jak-nakupovat


Kvalitní mobilní telefon pro rok 2012 by měl mít tyto, nebo ještě lepší parametry.
Značka Samsung , HTC, LG, Motorola, Sony Ericsson, ZTE Blade
Verze operačního systému Android 2.2 a vyšší.
Procesor a jeho frekvence Qualcomm 800MHz a vyšší.
Paměť RAM 512MB a více.
Paměť ROM 512MB.
Displej a jeho rozlišení 4,3 palce rozlišení 480x800 pixelů pro snadné ovládání a čtení a schopnost zobrazit 16 milionů barev.
Technologie 3G data, WiFi, BlueTooth, GPS přijímač, fotoaparát 3 Mpix, autofokus, diodový blesk.
Výdrž baterie minimálně 1 den a více.
3G internet.

samsung-s6102-galaxy-y-duos
18

long in java example | long-in-java-example


Android development

long is 64 bit signed type and used when int is not large enough to hold the value.

long je celé číslo 64 bitů -9223372036854775808 +9223372036854775807 a používá se tam, kde typ int není schopen pojmout takovou hodnotu čísla.


		// declaration and assignment of value type long
		long n = 22337203685477580L;
		// print formated value
		System.out.printf("The value of x is %d%n", n); // 22337203685477580
		System.out.format("%+,8d%n%n", n); // +22 337 203 685 477 580

		// declaring more variables in single statement
		long lo1 = 12L, lo2 = 56, lo3 = 1455555555589L;

		// long range of value
		System.out.println(Long.MAX_VALUE); // 9223372036854775807
		System.out.println(Long.MIN_VALUE); // -9223372036854775808

		// check if a string is a valid number in Java example
		// convert string to long Java example
		String sLong = "1288888888888888";
		long longParse = Long.parseLong(sLong);

		// convert strings to numbers
		long longFromString = (Long.valueOf(sLong)).longValue();

		// long to string in Java example code
		Long longObj = new Long(229999999999L);
		String str = longObj.toString();
		// else
		Long longS = 888888888888L;
		String strLong = longS.toString();

		// compare two long variables
		Long longComp1 = 5555L;
		if (longComp1.equals(55555555L))
			System.out.print("true");

		// compares the two specified long values in Java example

		int i = longS.compareTo(444444L); // -1 first < second
		// 0 first == second
		// 1 first > second
		System.out.print(i);
158

Check Internet connection Android example | check-internet-connection-android-example



public boolean isConnected() {
	 try {
		ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
		 return cm.getActiveNetworkInfo().isConnectedOrConnecting();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		Log.e("isConnected", e.getMessage());
		Toast.makeText(getApplicationContext(), e.getMessage(),
				Toast.LENGTH_LONG).show();
		return false;
	}


37

LayoutLib is too recent. Update your tool Eclipse Android | layoutlib-is-too-recent-update-your-tool-eclipse-android


LayoutLib is too recent. Update your tool!
Eclipse Android Graphical layout resolving problem.


  1. Open in Eclipse menu Help ->Check for Updates

  2. Select updates: [caption id="attachment_593" width="300" caption="Android Eclipse updates dialog"]android-eclipse-updates[/caption]


  3. Press Next and update all


  4. Restart Eclipse


  5. [caption id="attachment_596" align="alignleft" width="300" caption="Restart Eclipse if updates finished."]layoutlib-is-too-recent-update-your-tool[/caption]








Editace: 2013-12-09 13:10:51
Počet článků v kategorii: 397
Url:draw-drawargb-android-basic-example

AD
11 Share
Share
Tweet