-3

How to open new Activity by clicking [cardview] I am beginner and i have no idea of using [CardView] as a button. Help me i need example code

M Zaid Hayat
  • 11
  • 10

1 Answers1

0

I hope you added CardView in xml

CardView cardView=findViewById(R.id.cardView);
     cardView.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                Intent intent=new Intent(getApplicationContext(),YourActivityName.class);
                startActivtiy(intent);
            }
        });

add above code in your onCreate method

Suraj Vaishnav
  • 7,777
  • 4
  • 43
  • 46