public void showError(String result) {

    Selecciones.setError(result);

    final Intent main = new Intent(this, MainActivity.class);
    MainActivity.mSectionsPagerAdapter.setTrans(4);
    Selecciones.setError(result);
    startActivity(main);
    Intent mensaje = new Intent(this, Mensaje.class);
    startActivity(mensaje);
    finish();
  }
        public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {

          switch (menuItem.getItemId()) {
            case R.id.mostrarResultados:
              Selecciones.setCantidadElegidos(seleccionados);
              Selecciones.setElegidos(elegidos);
              if (seleccionados > 1) {
                final Intent compara = new Intent(getApplication(), ComparaArticulos.class);
                startActivity(compara);
                return true;
              }

              return false;
          }
          return false;
        }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.buscarMas:
        final Intent carac = new Intent(this.getApplication(), Caracteristicas.class);
        startActivity(carac);
        return true;

      case R.id.presupuesto:
        final Intent precio = new Intent(this, Precio.class);
        startActivity(precio);
        return true;

      case R.id.comparar:

        /*options.clear();
        getSupportMenuInflater().inflate(R.menu.comparar, options);*/
        startActionMode(mContentSelectionActionModeCallback);

        return true;
        /*case R.id.deshacer:
        options.clear();
        getSupportMenuInflater().inflate(R.menu.option, options);
        deshacer(anteojos);
        return true;*/
      case R.id.mostrarResultados:
        Selecciones.setElegidos(elegidos);
        Selecciones.setCantidadElegidos(seleccionados);
        if (seleccionados > 1) {
          final Intent compara = new Intent(this.getApplication(), ComparaArticulos.class);
          startActivity(compara);

          return true;
        } else {
          return false;
        }
    }

    return false;
  }
  public void getContents(String result) {

    json = result;
    Selecciones.setPreviousResult(result);
    int totalTab = 0;
    String clicked;
    Gson gson = new Gson();
    final Modelo[] recibidos = gson.fromJson(result, Modelo[].class);
    anteojos = recibidos;
    int total = recibidos.length;
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      HorizontalScrollView scroll = (HorizontalScrollView) findViewById(R.id.horizontalScrollView1);
      scroll.setBackgroundColor(Color.BLACK);
    }
    clicked = Selecciones.getSkuElegido();
    Log.d("clicked", clicked);
    ActionBar bar = getSupportActionBar();
    bar.setTitle("     " + Integer.toString(total) + "   Recomendaciones");

    LinearLayout lay = (LinearLayout) findViewById(R.id.linearLayout1);
    lay.removeAllViews();
    lay.setBackgroundColor(Color.BLACK);
    LinearLayout yellowLayout = (LinearLayout) findViewById(R.id.content);
    LinearLayout greenLayout = (LinearLayout) findViewById(R.id.content2);
    LinearLayout blueLayout = (LinearLayout) findViewById(R.id.content3);

    final Button[] parecidos = new Button[total];
    final Intent preview = new Intent(this, Preview.class);

    for (this.i = 0; i < total; i++) {

      parecidos[i] = new Button(this);
      try {

        InputStream ims = getAssets().open("images/" + recibidos[i].getSKU() + ".png");
        // load image as Drawable
        Drawable d = Drawable.createFromStream(ims, null);

        // set image to ImageView

        if (recibidos[i].getTab() != 0) {

          d = resizeSmall(d);
        } else {

          d = resize(d);
        }

        parecidos[i].setCompoundDrawablesRelativeWithIntrinsicBounds(null, d, null, null);

      } catch (IOException ex) {
        if (recibidos[i].getTab() == 0) {
          parecidos[i].setCompoundDrawablesRelativeWithIntrinsicBounds(
              0, R.drawable.opticageneral, 0, 0);
        } else {
          parecidos[i].setCompoundDrawablesRelativeWithIntrinsicBounds(
              0, R.drawable.opticageneralsmall, 0, 0);
        }
      }
      parecidos[i].setId(i + 100);
      recibidos[i].setModelo(recibidos[i].getModelo().trim());
      SpannableString text1 =
          new SpannableString(recibidos[i].getModelo() + "\n$" + recibidos[i].getPrecio().trim());
      text1.setSpan(new ForegroundColorSpan(Color.WHITE), 0, recibidos[i].getModelo().length(), 0);
      text1.setSpan(
          new ForegroundColorSpan(Color.RED),
          recibidos[i].getModelo().length(),
          2 + recibidos[i].getModelo().length() + recibidos[i].getPrecio().trim().length(),
          0);
      parecidos[i].setText(text1, BufferType.SPANNABLE);
      parecidos[i].setBackgroundColor(Color.BLACK);
      parecidos[i].setTextSize(20);
      parecidos[i].setClickable(true);

      parecidos[i].setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              int id = v.getId() - 100;

              Selecciones.setMarcaElegida(recibidos[id].getMarca());
              Selecciones.setModeloElegido(recibidos[id].getModelo());
              Selecciones.setColorElegido(recibidos[id].getColor());
              Selecciones.setFormaElegida(recibidos[id].getForma());
              Selecciones.setMaterialElegido(recibidos[id].getMaterial());
              Selecciones.setSkuElegido(recibidos[id].getSKU());
              Selecciones.setPrecioElegido(Integer.parseInt(recibidos[id].getPrecio().trim()));
              Selecciones.setStockElegido(recibidos[id].getStock());
              Selecciones.setBaseElegida(recibidos[id].getBase());
              Selecciones.setAroAltoElegido(recibidos[id].getAroAlto());
              Selecciones.setAroAnchoElegido(recibidos[id].getAroAncho());
              Selecciones.setDiagonalElegida(recibidos[id].getDiagonal());
              Selecciones.setPuenteElegido(recibidos[id].getPuente());

              startActivity(preview);
            }
          });

      if (total < 5) {

        if (recibidos[i].getTab() == 1) parecidos[i].setBackgroundColor(Color.MAGENTA);
        if (recibidos[i].getTab() == 3) parecidos[i].setBackgroundColor(Color.CYAN);

        try {

          InputStream ims = getAssets().open("images/" + recibidos[i].getSKU() + ".png");
          // load image as Drawable
          Drawable d = Drawable.createFromStream(ims, null);

          // set image to ImageView

          d = resize(d);

          parecidos[i].setCompoundDrawablesRelativeWithIntrinsicBounds(null, d, null, null);

        } catch (IOException ex) {
          parecidos[i].setCompoundDrawablesRelativeWithIntrinsicBounds(
              0, R.drawable.opticageneral, 0, 0);
        }

        lay.addView(parecidos[i]);

      } else {

        if (recibidos[i].getTab() == 0) lay.addView(parecidos[i]);
        if (recibidos[i].getTab() == 1) greenLayout.addView(parecidos[i]);
        if (recibidos[i].getTab() == 2) yellowLayout.addView(parecidos[i]);
        if (recibidos[i].getTab() == 3) blueLayout.addView(parecidos[i]);
      }
    }
    drawersHandler();
  }