Fel*_*lix 2 java android android-intent
我有3个类:MainActivity,DrawView和SecondActivity.MainActivity只是使用DrawView在屏幕上绘制一些东西.当我触摸Bitmap上的屏幕时,如何启动SecondActivity,我知道位图在哪里(在代码中).DrawView类的onTouchEvent函数.
@Override
public boolean onTouchEvent(final MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN: {
float posX = ev.getX();
float posY = ev.getY();
if(play.touched(posX, posY)==true){
} else {
}
return true;
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
该函数play.touched(posX,posY)返回一个布尔值(我创建了一个类,它位于Bitmap的位置).我如何从这里开始第二活动?
Cri*_*ian 10
if(play.touched(posX, posY)){
Intent intent = new Intent(getContext(), SecondActivity.class);
((Activity)getContext()).startActivity(intent);
} else {
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7000 次 |
| 最近记录: |