1 / 8

Picasso Revisted

Picasso Revisted. Updated Android wants gradle line to be “implementation” rather than previous “compile”. Change in gradle wants to be sync’ed again. Choose to Sync. Picasso site/documentation. Add Internet permission to manifest. main_activity.xml. <Button

bmohan
Télécharger la présentation

Picasso Revisted

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Picasso Revisted

  2. Updated Android wants gradle line to be “implementation” rather than previous “compile” Change in gradle wants to be sync’ed again

  3. Choose to Sync

  4. Picasso site/documentation

  5. Add Internet permission to manifest

  6. main_activity.xml <Button android:id="@+id/btnGetImage" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="18dp" android:layout_marginTop="15dp" android:text="Get image from URL" /> <ImageView android:id="@+id/ivFromURL" android:layout_width="fill_parent" android:layout_height="match_parent" android:adjustViewBounds="false" android:scaleType="fitXY" android:src="@mipmap/ic_launcher" />

  7. MainActivity.java package com.example.blum.myapplication;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.ImageView;import com.squareup.picasso.Picasso;public class MainActivity extends AppCompatActivity { ImageView imgFromURL; String url= "http://www.rewildthyself.com/wp-content/uploads/2015/03/poop.jpeg";@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);imgFromURL = (ImageView) findViewById(R.id.ivFromURL); Button btnGetImage = (Button) findViewById(R.id.btnGetImage); btnGetImage.setOnClickListener(new View.OnClickListener(){@Overridepublic void onClick(View v) { loadImageFromUrl(url); } //end onClick}); //end setOnClickListener} //end onCreateprivate void loadImageFromUrl(String url){// http://square.github.io/picasso/Picasso.get().load(url).into(imgFromURL); }}//end MainActivity

  8. Before and after clicking button

More Related