title: how to put single image from server into my imageview using volly in android?
body: <p><img src="https://i.stack.imgur.com/PZTmp.jpg" alt="enter image description here">
  <img src="https://i.stack.imgur.com/xGLqZ.jpg" alt="enter image description here"></p>
  
  <p>I have read a lot about fetching images from server and put it in  <code>listview</code> like that but here for activity i need to have single image from serve which should fit into all devices perfectly.how can i do this as i am new to android so dont know much about that..kindly help?And if can give any example then that would be very helpful.</p>
  
  <p>here is my MainActivity.class:</p>
  
  <pre><code>import android.content.Intent;
  import android.graphics.Bitmap;
  import android.net.Uri;
  import android.os.Bundle;
  import android.support.v7.app.ActionBar;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.ImageView;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.design.widget.NavigationView;
  import android.support.v4.view.GravityCompat;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.widget.Toolbar;
  
  import android.widget.TextView;
  import android.widget.Toast;
  import com.android.volley.Response;
  import com.android.volley.RequestQueue;
  import com.android.volley.VolleyError;
  import com.android.volley.toolbox.ImageRequest;
  import com.android.volley.toolbox.NetworkImageView;
  import com.android.volley.toolbox.Volley;
  import com.android.volley.Request;
  
  public class MainActivity extends AppCompatActivity
          implements NavigationView.OnNavigationItemSelectedListener, FragmentOne.OnFragmentInteractionListener,
          FragmentTwo.OnFragmentInteractionListener
  
  {
      ImageView im1, im2, im3;
      ImageLoader mImageLoader;
      ImageView mImageView;
      // The URL for the image that is being loaded.
      private static final String IMAGE_URL =
              "http://developer.android.com/images/training/system-ui.png";
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          im1 = (NetworkImageView) findViewById(R.id.ms1);
  
  
          ImageRequest imageRequest = new ImageRequest(IMAGE_URL, new Response.Listener&lt;Bitmap&gt;() {
              @Override
              public void onResponse(final Bitmap response) {
                  im1.setImageBitmap(response);
              }
          }, 0, 0, ImageView.ScaleType.CENTER_INSIDE, null, new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                  Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_LONG).show();
              }
          });
  
          RequestQueue requestQueue = Volley.newRequestQueue(MainActivity.this);
          requestQueue.add(imageRequest);
  
          if (savedInstanceState == null) {
              Fragment fragment = null;
              Class fragmentClass = null;
              fragmentClass = FragmentOne.class;
              try {
                  fragment = (Fragment) fragmentClass.newInstance();
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
              FragmentManager fragmentManager = getSupportFragmentManager();
              fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
          }
          im1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  startActivity(new Intent(MainActivity.this, Login.class));
              }
          });
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                  this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
          drawer.setDrawerListener(toggle);
          toggle.syncState();
  
          NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
          navigationView.setNavigationItemSelectedListener(this);
      }
  
  
  
      @Override
      public void onBackPressed() {
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          if (drawer.isDrawerOpen(GravityCompat.START)) {
              drawer.closeDrawer(GravityCompat.START);
          } else {
              super.onBackPressed();
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
              case R.id.action_settings:
                  // User chose the "Settings" item, show the app settings UI...
  
  
              case R.id.action_cart:
  
  
                  Intent ibs = new Intent(MainActivity.this,AddToCart.class);
                  ibs.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                  startActivity(ibs);
                  finish();
                  break;
              // User chose the "Favorite" action, mark the current item
              // as a favorite...
  
  
              default:
                  // If we got here, the user's action was not recognized.
                  // Invoke the superclass to handle it.
                  return super.onOptionsItemSelected(item);
  
          }
          return true;
      }
      @SuppressWarnings("StatementWithEmptyBody")
      @Override
      public boolean onNavigationItemSelected(MenuItem item) {
          // Handle navigation view item clicks here.
          int id = item.getItemId();
          Fragment fragment = null;
          Class fragmentClass = null;
          if (id == R.id.br_menu) {
              Intent i = new Intent(MainActivity.this,Login.class);
              startActivity(i);
  
          } else if (id == R.id.tr_ordr) {
              fragmentClass = FragmentTwo.class;
          } else if (id == R.id.pl_ordr) {
              fragmentClass = FragmentOne.class;
          } else if (id == R.id.profl) {
              fragmentClass = FragmentTwo.class;
          } else if (id == R.id.addr) {
              fragmentClass = FragmentOne.class;
          } else if (id == R.id.crds) {
              fragmentClass = FragmentTwo.class;
          }
          try {
              fragment = (Fragment) fragmentClass.newInstance();
          } catch (Exception e) {
              e.printStackTrace();
          }
          //FragmentManager fragmentManager = getSupportFragmentManager();
         //fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
  
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          drawer.closeDrawer(GravityCompat.START);
          return true;
      }
  
      @Override
      public void onFragmentInteraction(Uri uri) {
  
      }
  
  
  
  
  }
  </code></pre>
  
  <p>for m1 i need to set the imageview...</p>