Open Activity from OverlayItem

谁说我不能喝 提交于 2019-12-24 06:47:45

问题


How can I open an Activity from a OverlayItem: Here is my code now:

@Override
protected boolean onBalloonTap(int index) {

    if (index == 0) {
        c.startActivity(new Intent (c.getApplicationContext(),
                QuoteDetail.class));

This code works well to open a new Activity but I want to add this code to the code above:

public void onClick(View view) {
                 Intent i = new Intent(Test.this, QuoteDetail.class);
                 i.putExtra("position", 1);
                 startActivity(i);

How can I do this. Sorry for that stupid question, I´m a beginner


回答1:


private Context c;    
@Override
    protected boolean onBalloonTap(int index) {

        if (index == 0) { 
    Intent intent = new Intent(c, QuoteDetail.class);
                    intent.putExtra("position", 1);
                    c.startActivity(intent); 
                  }
        }


来源:https://stackoverflow.com/questions/11815676/open-activity-from-overlayitem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!