Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ProductActivity extends AppCompatActivity {
- public RecyclerView mRecyclerView;
- public ArrayList<Product> products;
- public ProductListAdapter productsAdapter;
- public final Context context = this;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_product);
- Toolbar toolbar = findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- FloatingActionButton addButton = findViewById(R.id.fab);
- DrawerLayout drawer = findViewById(R.id.drawerLayout);
- ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
- this, drawer, toolbar, 0, 0);
- drawer.addDrawerListener(toggle);
- toggle.syncState();
- mRecyclerView = findViewById(R.id.productRecyclerView);
- RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
- mRecyclerView.setLayoutManager(mLayoutManager);
- products = new ArrayList<>();
- products.add(new Product(0, "Test Nama Produk", "Berikut ini adalah contoh penjelasan nama produk",
- null, 2, 10000));
- products.add(new Product(1, "Test Nama Produk 2", "Berikut ini adalah contoh penjelasan nama produk",
- null, 50, 3000000));
- productsAdapter = new ProductListAdapter(this, products);
- mRecyclerView.setAdapter(productsAdapter);
- if(products.size() == 0){
- Toast.makeText(this, "Produk masih kosong.", Toast.LENGTH_SHORT).show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement