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.

Set Drawable programmatically Android example

// start_dark.png is stored in path	/package_name/res/drawable/start_dark.png
Drawable dw = getApplicationContext().getResources().getDrawable(R.drawable.start_dark);
Button hButtonStart = (Button)findViewById(R.id.buttonStart);
hButtonStart.setCompoundDrawablesWithIntrinsicBounds(dw, null, null, null);

397LW NO topic_id

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


layout id cannot be resolved or is not a field | layout-id-cannot-be-resolved-or-is-not-a-field

1.) check your xml files in res/layout folder if contain errors or warnings, repair this
2.) try comment import R in Activity file
// import com.mysite.packagename.R;
3.) every clean and rebuild project

No USB devices or running detected | no-usb-devices-or-running-detected


  • is sett debug mode on device?

  • enabled debugging over USB?

  • is device right connected?

  • have you downloaded and instaled drivers for your device on PC?

  • For Windows //developer.android.com/sdk/win-usb.html

  • try disconnect and connect USB cable

  • try do restart Android Studio


Expected resource of type raw drawable | expected-resource-of-type-raw-drawable

Try insert + before R.drawable.xxxx

// error
InputStream is = context.getResources().openRawResource(R.drawable.app_sample_code);

// ok
InputStream is = context.getResources().openRawResource(+R.drawable.app_sample_code);


How to capture screenshot of emulator window - Android sample | how-to-capture-screenshot-of-emulator-window-android-sample

When Eclipse and the emulator runs.
To access the DDMS perspective, go to Window > Open Perspective > DDMS. If DDMS does not appear, go to Window > Open Perspective > Other ... and select DDMS.

Open Devices TAB. Window -> Show view -> Devices

From Devices TAB select Screen Capture
Android emlator screen capture by eclipse

Eclipse update failed folder in use | eclipse-update-failed-folder-in-use

Failed to rename directory ....
If using for update Android SDK manager,
try close Eclipse if is open.
Or change security settings of the folder which have problem.
Or disable antivirus for a moment.

Editace: 2012-03-12 13:50:24
Počet článků v kategorii: 397