Add Permission in AndroidMainFest.xml File
<uses-permission android:name="android.permission.INTERNET" />
Add Library Glide in build.gradle File
compile 'com.github.bumptech.glide:glide:3.7.0'
MainActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.bhaumik.networkingtask.MainActivity">
<ImageView
android:id="@+id/image_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
MainActivity.java
package com.example.bhaumik.networkingtask;
import android.app.ProgressDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
public class MainActivity extends AppCompatActivity {
ImageView imageView;
String url = "https://static.pexels.com/photos/53966/rabbit-palm-hand-snatch-53966.jpeg";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = (ImageView) findViewById(R.id.image_view);
Glide.with(MainActivity.this).load(url).into(imageView);
}
}
0 comments:
Post a Comment