daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Oct 20th, 2018 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ProductActivity extends AppCompatActivity {
  2.  
  3.     public RecyclerView mRecyclerView;
  4.     public ArrayList<Product> products;
  5.     public ProductListAdapter productsAdapter;
  6.  
  7.     public final Context context = this;
  8.  
  9.     @Override
  10.     protected void onCreate(Bundle savedInstanceState) {
  11.         super.onCreate(savedInstanceState);
  12.         setContentView(R.layout.activity_product);
  13.  
  14.         Toolbar toolbar = findViewById(R.id.toolbar);
  15.         setSupportActionBar(toolbar);
  16.  
  17.         FloatingActionButton addButton = findViewById(R.id.fab);
  18.  
  19.         DrawerLayout drawer = findViewById(R.id.drawerLayout);
  20.         ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
  21.                 this, drawer, toolbar, 0, 0);
  22.  
  23.         drawer.addDrawerListener(toggle);
  24.         toggle.syncState();
  25.  
  26.         mRecyclerView = findViewById(R.id.productRecyclerView);
  27.         RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
  28.         mRecyclerView.setLayoutManager(mLayoutManager);
  29.  
  30.         products = new ArrayList<>();
  31.         products.add(new Product(0, "Test Nama Produk", "Berikut ini adalah contoh penjelasan nama produk",
  32.                 null, 2, 10000));
  33.         products.add(new Product(1, "Test Nama Produk 2", "Berikut ini adalah contoh penjelasan nama produk",
  34.                 null, 50, 3000000));
  35.  
  36.  
  37.         productsAdapter = new ProductListAdapter(this, products);
  38.         mRecyclerView.setAdapter(productsAdapter);
  39.  
  40.         if(products.size() == 0){
  41.             Toast.makeText(this, "Produk masih kosong.", Toast.LENGTH_SHORT).show();
  42.         }
  43.     }
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top