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.

Screen size density independent pixel resolution



Terms Screen size, density, density independent pixel, resolution as a picture - pictogram.
mobile-phone-screen-resolution-terms

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.

 

 

397LW NO topic_id



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


82

Switch Statement Java basic example | switch-statement-java-basic-example


Switch statement with numbers and array of strings Java example.


public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = { "One", "Two", "Three", "Four" };

		int i = 2;
		switch (i) {
			case 1: {
				System.out.println(arrayOfString[i]);
				break;
			}
			case 2: {
				System.out.println(arrayOfString[i]);
				break;
			}
			case 3: {
				System.out.println(arrayOfString[i]);
				break;
			}
			default: {
				System.out.println("Enter a valid value.");
			}
		} // END of switch
	}
}
/*
 * Three
 */




Possible:

case 1:
 System.out.println(arrayOfString[i]);
break;

// i love this notation 
case 1:{
 System.out.println(arrayOfString[i]);
}break;

case 1:{
 System.out.println(arrayOfString[i]);
 break;
}

111

Create RadioButton RadioGroup dynamically - Android sample | create-radiobutton-radiogroup-dynamically-android-sample



public class MainActivity extends Activity implements OnClickListener {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
            RadioGroup radioGroup = new RadioGroup(this);
            
            LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT
            );
            layout.addView(radioGroup, p);

            RadioButton radioButtonView = new RadioButton(this);
            radioButtonView.setText("RadioButton");
            radioButtonView.setOnClickListener(this);
            radioGroup.addView(radioButtonView, p);
            
            RadioButton radioButtonView2 = new RadioButton(this);
            radioButtonView2.setText("RadioButton2");
            radioButtonView2.setOnClickListener(mThisButtonListener);
            radioGroup.addView(radioButtonView2, p);
        
    }
    
    public void onClick(View view) {
    	 try {
    	  String s = ((RadioButton) view).getText().toString();
    	  Toast.makeText(MainActivity.this, "This is: " + s,
    			  Toast.LENGTH_LONG).show();
    	 }
    	 catch (Exception e1) {
    	   e1.printStackTrace();
    	 }
    	}
    
    private OnClickListener mThisButtonListener = new OnClickListener() {
        public void onClick(View v) {
        	String s = ((RadioButton) v).getText().toString();
        	Toast.makeText(MainActivity.this, "Hello from 2!" + s,
        			Toast.LENGTH_LONG).show();
        }
    };

}
325

Eclipse update failed folder in use | eclipse-update-failed-folder-in-use


Failed to rename directory ....
If using for update Android SDK manager,
try close Eclipse if is open.
Or change security settings of the folder which have problem.
Or disable antivirus for a moment.
234

goto statement in Java | goto-statement-in-java


You can use for, do while, while cycle for example:

public void myFunction(){
 for (int i = 0; i < 1; i++) {
	// some code
       int c = 10;
       if(c==10)
         break; // goto stop; in C++
 } // end of for
 // stop: // break moved process to end of for
 


 // next code

}


122

Eclipse Graphical Editor does not display a xml source code - error bug | eclipse-graphical-editor-does-not-display-code-error-bug


Try this solutions:
1.) Save xml file
2.) Close tab with xml file
3.) Reopen xml file

1.) Open from menu Window->Android SDK Manager
2.) Select available updates (Tools, SDK etc.)
3.) Install updates

1.) Open from menu Help->Check for Updates
2.) Install available plugins what You need
3.) Restart Eclipse




Editace Jana Žákovská : 2015-11-29 12:26:12
Počet článků v kategorii: 397
Url:screen-size-density-independent-pixel-resolution
Share
Share
Tweet