0

Im begginer for android studio, I have cardview at my home acvity, thats cardview just give information if email still not verified. And email has been verified, cardview must not show at home activity My question is, how we can remove cardview from home activity if email has been verified?

ADM
  • 20,406
  • 11
  • 52
  • 83
dody.ac
  • 77
  • 1
  • 4
  • 2
    Please attach some code of the things you have made, maybe just a cardview.visibility = View.GONE will be enough, if you are doing it on Kotlin – Dinorah Tovar Dec 26 '18 at 22:52

1 Answers1

1

I can not see exactly how your code works. But I can give you an idea of how you can get what you want.

You remove any view from the layout or just make them invisible. Create a reference for the CardView you want to hide in your Activity. Then apply the setVisibility(View.GONE) in the object you want to hide.

public class MainActivity extends AppCompatActivity {

    private CardView cardView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        cardView = findViewById(R.id.your_card_view_id_in_the_xml);

   }

   // then you hide the cardView in any method you want.
   private void anyMethod() {
    if (someCondition) {
      cardView.setVisibility(View.GONE);
   }


   /* 
      Note that if you use View.GONE the cardView will disappear from the UI.
      If you want to keep the empty space where the cardView you can do 
      it using cardView.setVisibility(View.INVISIBLE). And if you want to show 
      the card again just use cardView.setVisibility(View.VISIBLE)
   */


}

When posting questions here try to paste some code to help people to understand your problem better in a better way ok? Good practice! Happy coding!

Jesse Lima
  • 346
  • 4
  • 12
  • Thanks! Thats work! Sorry if im not attaching code, i just downloaded from android, and my code just at my PC. Ill try best next time – dody.ac Dec 26 '18 at 23:21
  • Nice! Great that it helped. When an answer is great for you and you can click on the up arrow in the left side of the answer. It's a good practice to give credit. Soon You will be here helping people two. Its just question of time. – Jesse Lima Jan 03 '19 at 18:20