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.

How to create mobile friendly page


AD MOB

If using Wordpress:
- update Wordpress
- download Plugin Any Mobile Theme Switcher and upzip into yourweb/wp-content/plugins/
- open Wordpress Dachboard on yourweb
- set defalut theme for desktop (Appearance - Theme)
- set themes for mobile users Settings - Any Mobile Theme Switcher for example Twentyfourteen theme
- preview page
- test page on Mobile Friendly Test

397LW NO topic_id




AD

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


102

Unable to resolve id for attribute id Graphical layout editor Eclipse error | unable-to-resolve-id-for-attribute-id-graphical-layout-editor-eclipse-error


Problem: erroneous entry of id

<RadioButton android:id="idRadio"
                android:text="My radio button"/>


Solution: @+id/

<RadioButton android:id="@+id/idRadio"
                android:text="My radio button"/>
78

Goto labeled statement in Java example | goto-labeled-statement-in-java-example


Goto in for cycle Java example source code.
MainClass.java

public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = {"nothing", "Hello", "people"
				, "bye-bye", "hello", "world!", "end" };
		
	    OuterLoop: for (int i = 0;i<6; i++) {
	        for (int j = 0; j < arrayOfString.length; j++) {
	        	if (arrayOfString[j].equals("world!")) {
	            continue OuterLoop; // as goto from Csharp, or C/C++
	          }
	          System.out.println(arrayOfString[j]);
	          System.out.println(i);
	          if (i == 1) {
	        	  System.out.println("break");
	        	  
	        	  break OuterLoop;
	          }
	        }
	      }
		
	}
}
/*
nothing
0
Hello
0
people
0
bye-bye
0
hello
0
nothing
1
break
*/
35

Android startup tutorial for developers video | android-startup-tutorial-for-developers-video


219

SparseArray instead HashMap Android example | sparsearray-instead-hashmap-android-example


Old code with HashMap

 Map<Integer, Bitmap> _bitmapCache = new HashMap<Integer, Bitmap>();
   private void fillBitmapCache() {
        _bitmapCache.put(R.drawable.icon, BitmapFactory.decodeResource(getResources(), R.drawable.icon));
        _bitmapCache.put(R.drawable.abstrakt, BitmapFactory.decodeResource(getResources(), R.drawable.abstrakt));
        _bitmapCache.put(R.drawable.wallpaper, BitmapFactory.decodeResource(getResources(), R.drawable.wallpaper));
        _bitmapCache.put(R.drawable.scissors, BitmapFactory.decodeResource(getResources(), 
    }

Bitmap bm = _bitmapCache.get(R.drawable.icon);

Lint warning:
Use new SparseArray(...) instead for better performance
Issue: Looks for opportunities to replace HashMaps with the more efficient SparseArray
Id: UseSparseArrays

New code with SparseArray

 SparseArray<Bitmap> _bitmapCache = new SparseArray<Bitmap>();
   private void fillBitmapCache() {
        _bitmapCache.put(R.drawable.icon, BitmapFactory.decodeResource(getResources(), R.drawable.icon));
        _bitmapCache.put(R.drawable.abstrakt, BitmapFactory.decodeResource(getResources(), R.drawable.abstrakt));
        _bitmapCache.put(R.drawable.wallpaper, BitmapFactory.decodeResource(getResources(), R.drawable.wallpaper));
        _bitmapCache.put(R.drawable.scissors, BitmapFactory.decodeResource(getResources(), 
    }

Bitmap bm = _bitmapCache.get(R.drawable.icon);


SparseArray methods:
//developer.android.com/reference/android/util/SparseArray.html
41

Preferences settings save open read write application Android example | preferences-settings-save-open-red-application-android-example


Android app setup preferences, settings, open, read, write, onStop(), onPause(), getSharedPreferences(), SharedPreferences.Editor getInt(), getBoolean(), getString() , putInt(), putString(), putBoolean() example source code.



import android.content.SharedPreferences;

public class MainClass extends Activity {
  public static final String PREFERENCES_NAME = "MyPrefsFile";
  String myNewString;
  int myNewInt;
  Boolean myNewBool;


   @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // read old settings if exist
      SharedPreferences settings = getSharedPreferences(PREFERENCES_NAME, 0);
			
     String sDefault = "Hello!";
      String sStringFromPrefFile = settings.getString("myString", sDefault); // new text  or default Hello!
          
      int nDefaultIndex = 2; //
      int nIndexFromPrefFile = settings.getInt("myInt", nDefaultIndex); // 4 or default 2
			
      Boolean bDefault = false;
      Boolean bFromPrefFile = settings.getBoolean("silentMode", bDefault); // true or default false
        
        
        // new settings will saved in onStop or onPause
        myNewString = "new text";
        myNewInt = 4;
        myNewBool = true;
     }   

    @Override
    protected void onPause() {
    	super.onPause();
        Toast.makeText(getApplicationContext(), "onPause "
        		, Toast.LENGTH_SHORT).show();

    	savePreferences();
    }
    
    @Override
    protected void onStop() {
    	super.onStop();
    	savePreferences();
    }
    /**save settings*/	
    public void savePreferences(){
    	try {
    		SharedPreferences settings = getSharedPreferences(PREFERENCES_NAME, 0);
    		SharedPreferences.Editor editor = settings.edit();
 
    		editor.putString("myString", myNewString);
     		editor.putInt("nMyInt", myNewInt);
    		editor.putBoolean("silentMode", myNewBool); // 
    		
    		editor.commit();
    	} catch (Exception e) {
    		// TODO Auto-generated catch block
    		e.printStackTrace();
    	}
    	
    }	
}


Editace: 2015-05-10 10:08:38
Počet článků v kategorii: 397
Url:how-to-create-mobile-friendly-page

AD
11 Share
Share
Tweet