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

Create new Android template in Eclipse

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

eclipse-show-template-proposals

Eclipse-show-template-proposals

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

Eclipse - select your template

	mIdButtonHome.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			Intent browserIntent = new Intent(Intent.ACTION_VIEW,
					Uri.parse("http://android.okhelp.cz/category/software/"));
			startActivity(browserIntent);
		}
	});

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

Eclipse quick help

This entry was posted in Android Examples Code, Eclipse and tagged . Bookmark the permalink.


Comments are closed.

8,254 views