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.

Download file from URL


AD MOB

Download image file from URL to ImageView Java Android source example code.



Context context = thisClass.this;
Drawable image = ImageOperations(context,
"//www.okhelp.cz/images/android/ad_4.png"
,"image.jpg");
ImageView imgView;
imgView = (ImageView)findViewById(R.id.idImageView);
imgView.setImageDrawable(image);

	private Drawable ImageOperations(Context ctx, String url, String saveFilename) {
		try {
			InputStream is = (InputStream) this.fetch(url);
			Drawable d = Drawable.createFromStream(is, "src");
			return d;
		} catch (MalformedURLException e) {
			e.printStackTrace();
			return null;
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}

	public Object fetch(String address) throws MalformedURLException,IOException {
		URL url = new URL(address);
		Object content = url.getContent();
		return content;
	}

397LW NO topic_id




AD

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


287

AlertDialog setButton Deprecated | alertdialog-setbutton-deprecated


Solution:

public void alertMy(String sTitle, String sMessage){
	AlertDialog.Builder builder = new AlertDialog.Builder(Test.this); // activity
  builder.setTitle(sTitle)
  .setMessage(sMessage)
  .setCancelable(false)
  .setNegativeButton("Close",new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
          dialog.cancel();
      }
  });
  AlertDialog alert = builder.create();
  alert.show();

}

212

Accessibility Missing contentDescription attribute on image | accessibility-missing-contentdescription-attribute-on-image


Android Emulator warning:[Accessibility] Missing contentDescription attribute on image

Workaround example code:
android:contentDescription="@string/desc"

            <ImageView
                android:id="@+id/imageViewOil"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
            android:contentDescription="@string/desc"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="84dp"
                android:src="@drawable/tank_silver" />
39

How setup color coloring syntax code highlight highlighting in Eclipse editor Android example | how-setup-color-syntax-highlight-in-eclipse-android-example


How setup color coloring highlight highlighting syntax font size and family in Eclipse Java and XML editor Android example
Java editor

  1. Go to Eclipse menu Window -> Preferences

  2. Doubleclick on Java

  3. Double click on Editor

  4. Select Java, Javadocs or Comments and setup color and font

  5. Font size and family change from Window->Preferences-> General->Appearance->Colors and Fonts


  6. Press OK for saving changes


xml editor
xml editor double click in Preferences dialog on xml -> Editor -> Syntax coloring
[caption id="attachment_627" align="alignleft" width="297" caption="Eclipse editor syntax color settings"]eclipse-color-syntax-highlight-settings[/caption]
302

Layout not found on Android 2.1 | layout-not-found-on-android-2-1


If I create own folder layout-w320dp with Eclipse Android 4.4
layout was correctly loaded.
If I trying this application on tablet with Android 2.1 application crashed.


layout-not-loaded-android-2-1
290

How disable Choreographer in LogCat Eclipse Android | how-to-disable-choreographer-messages


choreographer skipped frames
Create filter with TAG regex to disable Choreographer messages, see code and picture below:

^((?!Choreographer).)*$


choreographer-disable-remove


Editace: 2013-12-09 13:25:41
Počet článků v kategorii: 397
Url:download-file-from-url

AD
11 Share
Share
Tweet