Android, Can I use putExtra to pass multiple values

前端 未结 6 1585
北恋
北恋 2020-12-02 06:54

I want to pass two values to another activity can I do this with putExtra or do I have to do it a more complicated way, which it seems from my reading. E.g.. can something l

6条回答
  •  感动是毒
    2020-12-02 07:27

    Your example won't work, since the Extras are made out of a Key and a Value. You cant put multiple Keys and Values in one Extra

    Also, your keys need to be Strings as far as I know (and noticed) but I might be wrong on that one.

    Try this:

    public final static String ID_EXTRA="com.fnesse.beachguide._ID";
    
    Intent i = new Intent(this, CoastList.class);
    i.putExtra("ID_Extra", ID_EXTRA);
    i.putExtra("1", 111);
    startActivity(i);
    

提交回复
热议问题