title: How to make shorter code
body: <p>This is part of code from my first application. At the moment I have added just 2 TextViews with default value gab, where clicking on them popups PopupMenu with 6 values. By clicking any value in PopupMenu, value of TextView changes to the clicked value (not changing other not clicked TextView values). I am planning to add like 100 or maybe even more this kind of TextViews. Writing, copying and editing ID's and etc for each would be too messy.</p>
  
  <p>How this could be made shorted?
  Amount of values won't change (6), amount of ViewId (for example augli_mervieniba and bites_mervieniba) will be huge.</p>
  
  <pre><code>    public void popup_mervieniba(final View view)
      {
          PopupMenu popupMenu = new PopupMenu(this, view);
          MenuInflater menuInflater = popupMenu.getMenuInflater();
          popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
              @Override
              public boolean onMenuItemClick(MenuItem item) {
  </code></pre>
  
  <p>This part is for that if first TextView is clicked</p>
  
  <pre><code>              if (view==findViewById(R.id.augli_mervieniba))
  
                      switch (item.getItemId()) {
                          case R.id.gab:
                              TextView t_gab = (TextView) findViewById(R.id.augli_mervieniba);
                              t_gab.setText(R.string.gab);
                              return true;
                          case R.id.iep:
                              TextView t_iep = (TextView) findViewById(R.id.augli_mervieniba);
                              t_iep.setText(R.string.iep);
                              return true;
                          case R.id.g:
                              TextView t_g = (TextView) findViewById(R.id.augli_mervieniba);
                              t_g.setText(R.string.g);
                              return true;
                          case R.id.kg:
                              TextView t_kg = (TextView) findViewById(R.id.augli_mervieniba);
                              t_kg.setText(R.string.kg);
                              return true;
                          case R.id.ml:
                              TextView t_ml = (TextView) findViewById(R.id.augli_mervieniba);
                              t_ml.setText(R.string.ml);
                              return true;
                          case R.id.l:
                              TextView t_l = (TextView) findViewById(R.id.augli_mervieniba);
                              t_l.setText(R.string.l);
                              return true;
                  }
  </code></pre>
  
  <p>This part is for that if second TextView is clicked</p>
  
  <pre><code>            else if (view==findViewById(R.id.bietes_mervieniba))
                      switch (item.getItemId()) {
                          case R.id.gab:
                              TextView t_gab = (TextView) findViewById(R.id.bietes_mervieniba);
                              t_gab.setText(R.string.gab);
                              return true;
                          case R.id.iep:
                              TextView t_iep = (TextView) findViewById(R.id.bietes_mervieniba);
                              t_iep.setText(R.string.iep);
                              return true;
                          case R.id.g:
                              TextView t_g = (TextView) findViewById(R.id.bietes_mervieniba);
                              t_g.setText(R.string.g);
                              return true;
                          case R.id.kg:
                              TextView t_kg = (TextView) findViewById(R.id.bietes_mervieniba);
                              t_kg.setText(R.string.kg);
                              return true;
                          case R.id.ml:
                              TextView t_ml = (TextView) findViewById(R.id.bietes_mervieniba);
                              t_ml.setText(R.string.ml);
                              return true;
                          case R.id.l:
                              TextView t_l = (TextView) findViewById(R.id.bietes_mervieniba);
                              t_l.setText(R.string.l);
                              return true;
                  }
  </code></pre>
  
  <p>end of code</p>
  
  <pre><code>return false;
              }
          });
          menuInflater.inflate(R.menu.popup_mervieniba, popupMenu.getMenu());
          popupMenu.show();
      }
  </code></pre>