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 Studio add library dependencies to module project


  1. File->Project Structure Ctrl + Alt + Shift + S

  2. Select module and Dependencies Tab

  3. Click on + PLUS button (right upper corner)

  4. Select library

  5. Click OK, OK


397LW NO topic_id


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


Android Emulator PC keyboard shortcuts | android-emulator-pc-keyboard-shortcuts

Basic shortcuts for Android Emulator.

Emulated Device Key Keyboard Key
Menu (left softkey) F2 or Page-up button
Star (right softkey) Shift-F2 or Page Down
Back ESC
Call/dial button F3
Hangup/end call button F4
Search F5
Power button F7
Audio volume up button KEYPAD_PLUS, Ctrl-5
Audio volume down button KEYPAD_MINUS, Ctrl-F6
Camera button Ctrl-KEYPAD_5, Ctrl-F3
Switch to previous layout orientation (for example, portrait, landscape) KEYPAD_7, Ctrl-F11
Switch to next layout orientation (for example, portrait, landscape) KEYPAD_9, Ctrl-F12
Toggle cell networking on/off F8
Toggle code profiling F9 (only with -trace startup option)
Toggle fullscreen mode Alt-Enter
Toggle trackball mode F6
Enter trackball mode temporarily (while key is pressed) Delete
DPad left/up/right/down KEYPAD_4/8/6/2
DPad center click KEYPAD_5
Onion alpha increase/decrease KEYPAD_MULTIPLY(*) / KEYPAD_DIVIDE(/)

More about Android Emulator

How get Android SDK location on PC with Eclipse | how-get-android-sdk-location-on-pc-with-eclipse

How get Android SDK location - PATH on PC from Eclipse tutorial.

  1. Open dialog from menu Window -> AVD and SDK manager

  2. In dialog select Available packages

  3. On top of dialog will displayed similar path: SKD Location: C:\PROGRA~1\Android\android-sdk-windows\


Screen size density independent pixel resolution | screen-size-density-independent-pixel-resolution

Terms Screen size, density, density independent pixel, resolution as a picture - pictogram.

Test your knowledge
Q: How to find out the phone screen size?
A: (By length of display diagonale in inch -  Not to measure a diagonal of device!!!)

Q: What resolution has 720 x 1280 display?
A: (921600 pixels)

Q: What does it mean "240 dpi" screen density?
A: (Display have density 240 x 240  dots - "Tri-color LED etc." - per every physical (real) square inch. If you have icon 240x240 pixels, this will just occupy an area of one square inch on the display.)

Q: Phone have screen density 240 dpi. Image for 160 dpi screen density have size 128x 128 pixels. What will be the size of the image for 240 dpi screen density?
A: (Calculate the virtual pixels size.   128 * (240/160)  =  192.  You have to resize image to new size 192 x 192 physical pixels and put into folder drawable-hdpi (high) ~240dpi  for phone with screen density 240 dpi. ) or use density independend pixels 128dp x 128dp.



Date time difference determine which is earlier Android Java example | date-time-difference-between-two-dates

Date difference in millisecond between two date, GregorianCalendar, Calendar, after(), befor(), getTimeInMillis().

public class HoriziontalScrollActivity extends Activity {
TextView txtV;
	Context cntx;
    public void onCreate(Bundle savedInstanceState) {
        txtV = (TextView)findViewById(R.id.idLabel);
        cntx = this;
        StringBuilder strBuild = new StringBuilder();
        Calendar firstDate = new GregorianCalendar(2011, Calendar.DECEMBER, 31);
        Calendar secondDate = new GregorianCalendar(2012, Calendar.JANUARY, 1);

        Boolean bDetermine = firstDate.after(secondDate);            // false
        strBuild.append("Is firsDate after secondDate? " + bDetermine + "

"); bDetermine = firstDate.before(secondDate); // true strBuild.append("Is firsDate before secondDate? " + bDetermine + "
"); long differenceInMillisecond = 0L; differenceInMillisecond = secondDate.getTimeInMillis()-firstDate.getTimeInMillis(); // second == 1000 millisecond long second = differenceInMillisecond / 1000L; strBuild.append("Difference between two dates is: " + second + "
"); txtV.setText(strBuild); } }

Android Studio formatting code Ctrl + Alt + L | android-studio-formatting-code-ctrl-alt-l

Ctrl + Alt + L (format selection or all page)
Ctrl + Alt + Shift + L (show a dialog)
Ctrl + Windows Key + Alt + L

From menu Code
Code > Reformat Code

Editace: 2015-11-27 11:35:10
Počet článků v kategorii: 397

11 Share