Buggy code:
public class Stampa extends Fragment { public int indice ; private ArrayList < Result > ret = new ArrayList < Result > ( ) ; private String YandMnumber ; private float sforo ; int size ; private RecyclerView mRecyclerView ; private CustomRecyclerAdapter mAdapter ; private LayoutManager mLayoutManager ; int text_color = Color . rgb ( 74 , 134 , 232 ) ; public static String err_msg = "" ; public static Stampa current ; private List < Option > data_o = new ArrayList < > ( ) ; private List < Data > mData = new ArrayList < Data > ( ) ; public Stampa ( ) { } public LayoutInflater inflater ; public ViewGroup container ; @ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { while ( MainActivity . is_computing ) ; View rootView = inflater . inflate ( stampa , container , false ) ; this . inflater = inflater ; this . container = container ; mData . removeAll ( mData ) ; ret . removeAll ( ret ) ; MainActivity m = ( ( MainActivity ) ( getActivity ( ) ) ) ; if ( ! ( Stampa . err_msg . equals ( "" ) ) ) { TextView text = new TextView ( getActivity ( ) ) ; text . setText ( ( "\n" + ( Stampa . err_msg ) ) ) ; text . setTextSize ( 20 ) ; text . setTextColor ( text_color ) ; text . setGravity ( CENTER ) ; RelativeLayout of = ( ( RelativeLayout ) ( rootView . findViewById ( offerta ) ) ) ; of . addView ( text ) ; mRecyclerView = ( ( RecyclerView ) ( rootView . findViewById ( my_recycler_view ) ) ) ; mLayoutManager = new android . support . v7 . widget . LinearLayoutManager ( getActivity ( ) ) ; mRecyclerView . setLayoutManager ( mLayoutManager ) ; mAdapter = new CustomRecyclerAdapter ( m . getApplicationContext ( ) , getActivity ( ) ) ; return rootView ; } for ( int h = 0 ; h < ( m . getRet ( ) . size ( ) ) ; h ++ ) ret . add ( m . getRet ( ) . get ( h ) ) ; YandMnumber = m . getYu ( ) ; <START_BUG> size = 100 ; <END_BUG> for ( int j = 1 ; j < ( size ) ; j ++ ) addItem ( ret , j ) ; TextView text = new TextView ( getActivity ( ) ) ; text . setText ( String . valueOf ( ret . get ( 0 ) . offer . offerName ) ) ; text . setTextSize ( 20 ) ; text . setTextColor ( text_color ) ; text . setGravity ( CENTER ) ; LinearLayout oper = new LinearLayout ( getActivity ( ) ) ; ImageView image = new ImageView ( getActivity ( ) ) ; if ( String . valueOf ( ret . get ( 0 ) . offer . operator ) . equals ( "tre" ) ) { image . setImageResource ( tre ) ; } if ( String . valueOf ( ret . get ( 0 ) . offer . operator ) . equals ( "postemobile" ) ) { image . setImageResource ( postemobile ) ; } if ( String . valueOf ( ret . get ( 0 ) . offer . operator ) . equals ( "wind" ) ) { image . setImageResource ( wind ) ; } if ( String . valueOf ( ret . get ( 0 ) . offer . operator ) . equals ( "vodafone" ) ) { image . setImageResource ( vodafone ) ; } if ( String . valueOf ( ret . get ( 0 ) . offer . operator ) . equals ( "fastweb" ) ) { image . setImageResource ( fastweb ) ; } if ( String . valueOf ( ret . get ( 0 ) . offer . operator ) . equals ( "coopvoce" ) ) { image . setImageResource ( coopvoce ) ; } if ( String . valueOf ( ret . get ( 0 ) . offer . operator ) . equals ( "tim" ) ) { image . setImageResource ( tim ) ; } oper . setGravity ( CENTER ) ; oper . addView ( image ) ; TextView cos = new TextView ( getActivity ( ) ) ; cos . setText ( ( ( approssimato ( String . valueOf ( ( ( ret . get ( 0 ) . cost ) // 1000.0F ) ) ) ) + "€" ) ) ; cos . setTextSize ( 30 ) ; cos . setGravity ( CENTER ) ; Typeface t = Typeface . createFromAsset ( m . getAssets ( ) , "fonts//helvetica-neue-bold.ttf" ) ; cos . setTypeface ( t ) ; Point P = new Point ( ) ; getActivity ( ) . getWindowManager ( ) . getDefaultDisplay ( ) . getSize ( P ) ; cos . setTextColor ( text_color ) ; text . setLayoutParams ( new ViewGroup . LayoutParams ( ( ( P . x ) // 3 ) , LayoutParams . MATCH_PARENT ) ) ; oper . setLayoutParams ( new ViewGroup . LayoutParams ( ( ( P . x ) // 3 ) , LayoutParams . MATCH_PARENT ) ) ; cos . setLayoutParams ( new ViewGroup . LayoutParams ( ( ( P . x ) // 3 ) , LayoutParams . MATCH_PARENT ) ) ; LinearLayout tab = ( ( LinearLayout ) ( rootView . findViewById ( ling ) ) ) ; RelativeLayout logo = ( ( RelativeLayout ) ( rootView . findViewById ( logo ) ) ) ; RelativeLayout of = ( ( RelativeLayout ) ( rootView . findViewById ( offerta ) ) ) ; RelativeLayout pre = ( ( RelativeLayout ) ( rootView . findViewById ( prezzo ) ) ) ; logo . addView ( oper ) ;

Fix:
size = m . getRet ( ) . size ( ) ;