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.

Start an new Activity Intent with a parameter Android example


putString(), putBoolean(), putInt() etc.¨
How we can start an activity programmatically.

// MainActivity.java
//  myButton.setOnClickListener
Intent binary = new Intent(getApplicationContext(),Calculate.class);
	Bundle b = new Bundle();
	b.putString("prvni_label", "Decimal");
	b.putString("druhy_label", "Binary");
	b.putString("mode", "binary_to_decimal");
	startActivityForResult(binary, 0);
// in Calculate.java onCreate

   TextView mTextView1 = (TextView)findViewById(R.id.textView1);
   TextView mTextView2 = (TextView)findViewById(R.id.textView2);    
     Bundle _bundle = getIntent().getExtras();

//.................. HOW OPEN START NEW ACTIVITY WITHOUT A PARAMETER .........................

startActivity(new Intent(ThisActivity.this, NewActivity.class));

397LW NO topic_id


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


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

[caption id="attachment_1114" align="alignleft" width="300" caption="Eclipse-show-template-proposals"]eclipse-show-template-proposals[/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"][/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

Eclipse quick help

SQLite explorer download | sqlite-explorer-download

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

Eclipse "id cannot be resolved or is not a field” error Android | eclipse-id-cannot-be-resolved-or-is-not-a-field-error-android

"id cannot be resolved or is not a field” error
If you copy project to workspace or some code from other project you can get this error.

Try remove or add import your R file:

import com.example.app.R

Check xml files.
Clean project by menu Project-Clean

Maybe you have to create new project end copy old source files to new project folders.

Unable to execute dex: Multiple dex files define Eclipse Android | unable-to-execute-dex-multiple-dex-files-define-eclipse-android

Try each step separately:

  1. Restart Eclipse

  2. Clean project and rebuild

  3. Create a new project and try it if the problem persists, if no move copy project to other folder, delete project from workspace , create new project same name and copy java, xml etc. files to new project

  4. Close Eclipse, backup folder c:\Users\myName\workspace\.metadata and delete it. Restart Eclipse try again import project to workspace

  5. Re-installing the Android Developer Tools

  6. Re-installing Eclipse - rename old folder with Android to Android_old, create new folder C:\Program Files\Android and copy new Eclipse with sdk into new folder

  7. Created a new project importing from the file system

  8. Created a new project from subversion


How get Drawable Android example | how-get-drawable-android-example

InputStream, getResources(),openRawResource()

 java.io.InputStream is;
is = context.getResources().openRawResource(R.drawable.my_image);

Drawable mDrawable = context.getResources().getDrawable(R.drawable.button);
mDrawable.setBounds(150, 20, 300, 100);

Drawable[] mDrawables;
int[] resIDs = new int[] {
            mDrawables = new Drawable[resIDs.length];
            Drawable prev = mDrawable;
            for (int i = 0; i < resIDs.length; i++) {
                mDrawables[i] = context.getResources().getDrawable(resIDs[i]);
                addToTheRight(mDrawables[i], prev);
                prev = mDrawables[i];

Editace: 2013-01-27 22:37:38
Počet článků v kategorii: 397

11 Share