Card View Click on Card Move To New Activity

后端 未结 6 1729
死守一世寂寞
死守一世寂寞 2021-02-07 03:39

I am new to Android programming and was working on a card layout. I was wondering, how do I make it clickable?

android:clickable=\"true\"
android:foreground=\"?         


        
6条回答
  •  遇见更好的自我
    2021-02-07 04:26

    If you used the implementation correctly, your code should go like this:

    card - is the card view you instantiated to display on your ui
    
    
    card.setOnClickListener(...);
    

    In your implementation of the onClickListener, you should have this:

    @Override
    public void onClick(Card c ,View v) {
        Intent intent = new Intent(MyActivity.this, NextActivity.class);
        startActivity(intent);
    }
    

    that is pretty much all you need to start a new activity from the card

提交回复
热议问题