Download presentation
Presentation is loading. Please wait.
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:layout_height="match_parent" android:adjustViewBounds="false" android:scaleType="fitXY" />
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= " @Override protected 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(){ @Override public void onClick(View v) { loadImageFromUrl(url); } //end onClick }); //end setOnClickListener } //end onCreate private void loadImageFromUrl(String url){ // Picasso.get().load(url).into(imgFromURL); } }//end MainActivity
8
Before and after clicking button
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.