Buggy code:
public class CartActivity extends ActionBarActivity { private List < CartEntry > cart_entries ; private Dialog dialog ; private RuntimeExceptionDao < CartEntry , Integer > dao ; private RecyclerViewAdapter adapter ; @ Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( activity_cart ) ; dao = DatabaseHelper . getHelper ( getApplicationContext ( ) ) . getCartEntryDao ( ) ; RecyclerView cart_rv = ( ( RecyclerView ) ( findViewById ( cart_recycler_view ) ) ) ; LinearLayoutManager llm = new LinearLayoutManager ( this ) ; cart_rv . setLayoutManager ( llm ) ; cart_rv . setHasFixedSize ( true ) ; cart_entries = dao . queryForAll ( ) ; adapter = new RecyclerViewAdapter ( cart_entries ) ; cart_rv . setAdapter ( adapter ) ; cart_rv . addOnItemTouchListener ( new RecyclerItemClickListener ( this , cart_rv , new RecyclerItemClickListener . OnItemClickListener ( ) { @ Override public void onItemClick ( View view , int position ) { Toast . makeText ( CartActivity . this , cart_entry_popup_info , LENGTH_SHORT ) . show ( ) ; } @ Override public void onItemLongClick ( View view , final int position ) { dialog = new Dialog ( CartActivity . this ) ; <START_BUG> dialog . setContentView ( cart_entry_popup ) ; <END_BUG> dialog . setTitle ( cart_entry_popup_title ) ; CartEntry temp = cart_entries . get ( position ) ; EditText amount = ( ( EditText ) ( dialog . findViewById ( cart_entry_popup_input ) ) ) ; amount . setText ( String . valueOf ( temp . getAmount ( ) ) ) ; TextView unit = ( ( TextView ) ( dialog . findViewById ( cart_entry_popup_unit ) ) ) ; if ( ( temp . getUnit ( ) ) == null ) { unit . setText ( cart_entry_unit_null_exception ) ; } else { unit . setText ( temp . getUnit ( ) ) ; } Button button_ok = ( ( Button ) ( dialog . findViewById ( cart_entry_popup_ok ) ) ) ; Button button_cancel = ( ( Button ) ( dialog . findViewById ( cart_entry_popup_cancel ) ) ) ; button_cancel . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { dialog . dismiss ( ) ; } } ) ; button_ok . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { TextView temp = ( ( TextView ) ( dialog . findViewById ( cart_entry_popup_input ) ) ) ; if ( temp . getText ( ) . toString ( ) . isEmpty ( ) ) { Toast . makeText ( CartActivity . this , cart_entry_popup_valid_amount , LENGTH_LONG ) . show ( ) ; return ; } double amount_new = Double . parseDouble ( temp . getText ( ) . toString ( ) ) ; cart_entries . get ( position ) . setAmount ( amount_new ) ; dao . update ( cart_entries . get ( position ) ) ; cart_entries . get ( position ) . getProductId ( ) ; adapter . notifyItemChanged ( position ) ; dialog . dismiss ( ) ; } } ) ; dialog . show ( ) ; } } ) ) ; TextView total_price = ( ( TextView ) ( findViewById ( cart_total_price ) ) ) ; int total = 0 ; for ( int i = 0 ; i < ( cart_entries . size ( ) ) ; i ++ ) { total += ( cart_entries . get ( i ) . getPrice ( ) ) * ( cart_entries . get ( i ) . getAmount ( ) ) ; } total_price . setText ( ( total + "<seq2seq4repair_space>Euro" ) ) ; if ( ( cart_entries . size ( ) ) == 0 ) { TextView title = ( ( TextView ) ( findViewById ( cart_empty ) ) ) ; title . setText ( Html . fromHtml ( getString ( R . string . cart_empty ) ) ) ; title . setVisibility ( VISIBLE ) ; } } No newline ; at end ; of file ; }

Fix:
dialog . setContentView ( cart_entry_dialog ) ;