title: How to change textview and imageview content on next and previous buttons in Android?
body: <p>I am making an app where images have to go next and back in imagview and text as description in textview also go along with image(different text) can someone write code for changing text with the image i am using hash map but on one string come in textview.</p>
  
  <pre><code>    public class MainActivity extends AppCompatActivity {
      private static Button button, butto2,reset_bu, auto;
      private static ImageView imageView;
      private static TextView textView;
      private int i=0;
      private Handler handler = new Handler();
      // image resource
      int[] images = {R.drawable.im_1, R.drawable.im_2, R.drawable.im_3,  
              R.drawable.im_24, R.drawable.im_25, R.drawable.im_26, 
                  R.drawable.im_27, R.drawable.im_28, R.drawable.im_29, 
                  R.drawable.im_30, R.drawable.im_31, R.drawable.im_32,
              R.drawable.im_33, R.drawable.im_34, R.drawable.im_35, 
               R.drawable.im_36, R.drawable.im_37, R.drawable.im_38, 
                  R.drawable.im_39, R.drawable.im_40, R.drawable.im_41,
              R.drawable.im_42, R.drawable.im_43, R.drawable.im_44, 
              R.drawable.im_45,};
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          button = (Button) findViewById(R.id.button);
          butto2 = (Button) findViewById(R.id.button2);
          reset_bu = (Button) findViewById(R.id.reset_bu);
          final TextView textView = (TextView) findViewById(R.id.textView);
         // auto = (Button) findViewById(R.id.auto);
        //  imageView = (ImageView) findViewById(R.id.imageView);
  
          addListenerOnButton();
          setInitialImage();
          addback();
          reset();
  
      }
      public void addListenerOnButton () {
      button.setOnClickListener(new OnClickListener() {
      @Override public void onClick(View v) {
        if (i &lt; images.length -1){
         i++;
         i = i % images.length;
         setCurrentImage();
  
                         }
      } });
      }
      private void setInitialImage() {
          setCurrentImage();
      }
      private void setCurrentImage() {
          final ImageView imageView = (ImageView) findViewById(R.id.imageView);
          imageView.setImageResource(images[i]);
     final TextView textView=(TextView)findViewById(R.id.textView);
     final HashMap&lt;Integer, Integer&gt; map = new HashMap&lt;&gt;();
                      map.put(R.drawable.im_1, R.string.busort);
                      map.put(R.drawable.im_2, R.string.busort2);
                      int busort = map.get(R.drawable.im_1);
                      int busort2 = map.get(R.drawable.im_2);
                      int busort3 = map.get(R.drawable.im_3);
                      String text1 = getResources().getString(busort);
                      String text12 = getResources().getString(busort2);
  
                      textView.setText(busort);
                      textView.setText(busort2);
  
      }
     public void addback(){
          butto2.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (i &gt; 0){
                      i--;
                      i = i % images.length;     
                      setCurrentImage();
                  }
  
              }
  
          });
  
          }
          public void reset(){
              reset_bu.setOnClickListener(new OnClickListener() {
                  @Override
                  public void onClick(View v) {
  
                      i=0;
                      setCurrentImage();
  
                      }
              });
          }
     }
  </code></pre>
  
  <p>code for changing text as image description(on string value for each image) is required.</p>