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 add Android code templates to Eclipse

If you have to type frequently the same code you can create templates which can be activate via autocomplete with Ctrl + Space.

For example lets assume setOnClickListener body.

To create a template for this select the menu Window->Preferences and Open Java -> Editor -> Templates


Type name of template in Eclipse s editor and pres Ctrl+Space

[caption id="attachment_1114" align="alignleft" width="300" caption="Eclipse-show-template-proposals"]android/eclipse-show-template-proposals-300x222.png[/caption]

Select your template from intellisense help and press Enter or double click on selected item.

[caption id="attachment_1116" align="alignleft" width="300" caption="Eclipse - select your template"]android/eclipse-show-template-proposals-2-300x187.png[/caption]

	mIdButtonHome.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			Intent browserIntent = new Intent(Intent.ACTION_VIEW,

Quick help in Eclipse editor: select keyword and press Ctrl+1


396LW NO topic_id


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


How quickly restart adb.exe ADB server Android emulator example | how-quickly-restart-adb-exe-adb-server-android-emulator-example

Create file restartADB.bat in folder
c:\Program Files\Android\android-sdk-windows\platform-tools\
Write into restartADB.bat this code:

adb kill-server && adb start-server

Save restartADB.bat file.
If you want restart adb.exe server, run restartADB.bat by double click on icon.

Next example:

  1. Open Total Commander

  2. Open folder with adb.exe usually in
    c:\Program Files\Android\android-sdk-windows\platform-tools\

  3. Put into command line command: adb kill-server && adb start-server and press Enter

[caption id="attachment_778" align="alignleft" width="300" caption="ADB server restart by command line"]android/adb-restart-server-android-emulator-300x188.png[/caption]

Try restart ADB if this or similar errors:
Emulator] emulator: emulator window was out of view and was recentred


Timer task TimerTask run cancel Android example | timer-task-timertask-run-cancel-android-example

Update TextView from TimerTask, Handler, schedule, run, cancel TimerTask, Android example

public class TimerActivity extends Activity {
	TimerTask mTimerTask;
	final Handler handler = new Handler();
	Timer t = new Timer();	
TextView hTextView;
TableRow hTableRow;
Button hButton, hButtonStop;

private int nCounter = 0;
    public void onCreate(Bundle savedInstanceState) {
        hTextView = (TextView)findViewById(R.id.idTextView);
        hButton = (Button)findViewById(R.id.idButton);
        hButtonStop = (Button)findViewById(R.id.idButtonStop);

    } // end onCreate

View.OnClickListener mButtonStartListener = new OnClickListener() {
	public void onClick(View v) {

	View.OnClickListener mButtonStopListener = new OnClickListener() {
    	public void onClick(View v) {
    public void doTimerTask(){

    	mTimerTask = new TimerTask() {
    	        public void run() {
    	                handler.post(new Runnable() {
    	                        public void run() {
                                        // update TextView
    	                        	hTextView.setText("Timer: " + nCounter);

    	                        	Log.d("TIMER", "TimerTask run");

            // public void schedule (TimerTask task, long delay, long period) 
    	    t.schedule(mTimerTask, 500, 3000);  // 


    	  public void stopTask(){

    	      hTextView.setText("Timer canceled: " + nCounter);

    	      Log.d("TIMER", "timer canceled");


Snow Text Effects Paint.NET | snow-text-effects-paint-net

For some graphics you can use Paint.NET editor.
How create Snow Effects on Text by 1 minute show this video: