[Reprint] load a line of code to the ImageView-Android Picasso,
Original article link: Load a network image to ImageView-Android Picasso
Here we will introduce an Android framework: Picasso.
Picasso is an open-source Android image cache library of Square. The address is http://square.github.io/picasso/. you can download and save images. Only one line of code is required to fully implement asynchronous loading of images. The Code is as follows:
public class MainActivity extends Activity { private ImageView imageView; private String url="http://h.hiphotos.baidu.com/image/pic/item/64380cd7912397dd6e6c3adf5c82b2b7d1a287d0.jpg"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView=(ImageView) findViewById(R.id.TestImageID); Picasso.with(this).load(url).into(imageView); }}
The key line of code is as follows:
Picasso.with(this).load(url).into(imageView);
During the test, you still need to add the network access permission to AndroidManifest. xml.
<uses-permission android:name="android.permission.INTERNET" />