lundi 1 février 2021

How can I check the condition to show the text from makeText

I want to show "Favorite is empty" when there is no data to retrieve. However, it only work for else statement and it doesn't work in if statement . How can I check it is empty or not. I want to do like this the program will work as I coded when user click the button. But if there is not data to work when user click the button, program should show text from if statement

Here is my code

if(wishlist_item.size()>=1){
                    L1.setOnClickListener(new View.OnClickListener() {
                        String a = wishlist_item.get(0);
                        @Override
                        public void onClick(View view) {
                            if(a.isEmpty()){
                                Toast.makeText(wish_list.this, "Favourite is empty", Toast.LENGTH_SHORT).show();
                            }else{
                                Intent launchWish = new Intent(wish_list.this,web_view2.class);
                                launchWish.putExtra("k",a);
                                startActivity(launchWish);
                            }
                        }
                    });
                }

Aucun commentaire:

Enregistrer un commentaire