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.

SQLite explorer download


AD MOB

Best of SQLite explorer and admin download for SQLite 2.x and SQLite 3.x in separated folders.

Download Explorers SQLite 2.x and SQLite 3.x in separated folders

397LW NO topic_id




AD

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


164

Immutable bitmap passed to Canvas constructor - Android error | immutable-bitmap-passed-to-canvas-constructor-android-error


Try this source code:

Bitmap myBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.my_image)
.copy(Bitmap.Config.ARGB_8888, true);
Canvas c = new Canvas(myBitmap);
// etc.  ....... 


Issue: Immutable bitmap passed to Canvas constructor
Solution: Bitmap myBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.my_image)
.copy(Bitmap.Config.ARGB_8888, true);
224

Eclipse my templates store Android | eclipse-my-templates-store-android


Where file(s) does eclipse store Java code style settings to?
If you need copy any old templates to the new workspace.

workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.ui.prefs


You can edit the Eclipse Templates from menu Window - Preferences - Java - Editor - Templates.
86

Map TreeMap key value pair add put get pair by key Java Android example | map-treemap-key-value-pair-add-put-get-pair-by-key-java-android-example


Map TreeMap add key value pair get find pair by key Java Android example.

MainClass.java

import java.util.Map;
import java.util.TreeMap;

public class MainClass {
	public static void main(String[] arg) {
		
		// english;germany dictionary
		String[] arrayOfString = { "one;eine", "two;zwei", "three;drei" };

		Map<String, String> map = new TreeMap<String, String>();
	    
		for(String s: arrayOfString){
	    	String[] array = s.split(";");
	    	String sKey ="", sValue="";
	    	if(array.length > 1){
	    	sKey = array[0]; sValue = array[1];
	    		map.put(sKey, sValue);
	    	}
	    }

       // check if key exists 	    
	   if( map.containsKey("two")){
		System.out.print("two = " + map.get("two"));
	   }
	}
}
/*
two = zwei
 */

31

Start Activity from ListView item click Android example | start-activity-from-listview-item-click-android-example


How start certain Activity if user clicked to ListView item
Start Activity from list – launches other activities from list - latest variant!!!!


public class Main extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        try {
        setContentView(R.layout.main);
        
			ListView mlistView = (ListView) findViewById(R.id.idListView);
			mlistView.setAdapter(new ArrayAdapter<String>(this,
			        android.R.layout.simple_list_item_1, 
			        new String[] {"Game", "Help", "Home site"}));
    
        mlistView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
              // When clicked, show a toast with the TextView text Game, Help, Home
              Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
                  Toast.LENGTH_SHORT).show();
              String sText = ((TextView) view).getText().toString();
              Intent intent = null;
              if(sText.equals("Game"))
              intent = new Intent(getBaseContext(),
						Game.class);
              //else if(sText.equals("Help")) ..........

              if(intent != null)
				startActivity(intent);              
            }
          });
        } catch (Exception e) {
        	// TODO Auto-generated catch block
        	e.printStackTrace();
        }
    
    }
}



Game class Game.java game.xml
You have to add class Game to AndroidManifest.xml

        <activity android:name=".Game" android:label="GameLabel">
        </activity>





package cz.okhelp.listview;

import android.app.Activity;
import android.os.Bundle;

public class Game extends Activity{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // you have to create game.xml 
        setContentView(R.layout.game);
    }
}




26

Get package name Context-getPackageName Android example | get-package-name-context-getpackagename-android-example


If you often copy your Android project to another you have to using function for obtaining varied information about package.
This code show how get package name in Android application as string:

Context context = getContext(); // this.getContext(); getApplicationContext(); etc.
String sPackName = context.getPackageName();



Editace: 2011-09-26 20:51:10
Počet článků v kategorii: 397
Url:sqlite-explorer-download

AD
11 Share
Share
Tweet