0 голосов
 
471 просмотр
3.10.2019 / 06:38  miniyu

Как открить новое активити ?

Как открить новое активити из холста ?
  1. import android.content.*;
  2. import android.graphics.*;
  3. import android.view.*;
  4. import miniyu.spirit.speaker.window.*;
  5. import android.app.Activity;
  6. import android.os.Bundle;
  7. import miniyu.spirit.speaker.input.inputLogin;
  8.  
  9. public class Midlet extends View
  10. {  
  11.     int W, H;
  12.     private Paint paint;
  13.     Paint fontPaint;
  14.     public MainMenu _MainMenu;
  15.     public Login _Login;
  16.     public static int game_state=0;
  17.     public Midlet(Context context)
  18.     {
  19.         super(context);
  20.         _MainMenu = new MainMenu();
  21.         _Login = new Login();
  22.         paint = new Paint();
  23.         fontPaint = new Paint();
  24.     }
  25.  
  26.     protected void onDraw(Canvas g)
  27.     {
  28.         super.onDraw(g);
  29.         fontPaint.setColor(Color.RED);
  30.         fontPaint.setTextSize(30f);
  31.  
  32.         W = getWidth();
  33.         H = getHeight();
  34.         g.drawColor(Color.BLACK);
  35.  
  36.         if(game_state==0){
  37.             _MainMenu.draw(g);
  38.         }else if (game_state==1){
  39.             _Login.draw(g);
  40.         }else if(game_state==2){
  41.  
  42.         }
  43.  
  44.         paint.setColor(Color.RED);
  45.         g.drawText("fps:"+Fps.fps()+" screen size: "+ W+"x"+H,3,45,fontPaint);
  46.  
  47.         invalidate();
  48.     }
  49.     @Override
  50.     public boolean onTouchEvent(MotionEvent event) {
  51.         if(game_state==0){
  52.         if (event.getAction() == MotionEvent.ACTION_DOWN) {
  53.  
  54.             Intent intent = new Intent(MainActivity.this, inputLogin.class);
  55.             startActivity(intent);
  56.  
  57.             _MainMenu.handleActionDown((int)event.getX(), (int)event.getY());
  58.             }
  59.         if (event.getAction() == MotionEvent.ACTION_UP) {
  60.             //прерывание последнего касания
  61.             if (_MainMenu.isTouched()) {
  62.                 _MainMenu.setTouched(false);
  63.             }
  64.         }
  65.         }
  66.         return true;
  67.     }
  68. }
Ответы
Ответов нет
Всего: 0

Реклама

Мы в соцсетях

tw tg yt gt