2017-10-12 14 views
-1

ボタンのクリック後に同じアクティビティがリロードされますが、これは別のアクティビティを意図していましたが、コードはかなり正常で基本的ですが、問題を知ることができません。Androidスタジオで1つのアクティビティから別のアクティビティに変更できません(ページがリロードされます)

パブリックボイドのinit(){ImageButtonドライバ=(ImageButton)findViewById(R.id.driver);新しいイントネータ(新しいインテント(MapsActivity.this、Driverlogin.class); startActivity(ログイン);}})); } @Override protected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);} setContentView(R.layout.activity_maps); if(android.os.Build.VERSION.SDK_INT> = Build.VERSION_CODES.M){checkLocationPermission(); } // SupportMapFragmentを取得し、マップの使用準備ができたら通知を受け取る。 SupportMapFragment =(SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this);その中に(); }

+0

これは「コードは正常かつ基本的」です。またエラーログがある場合は –

+0

@shashi sekharあなたの通常のコードを追加してください – nomag

+0

私の質問が更新されました。 –

答えて

1
public void init() 
{ 
    ImageButton driver=(ImageButton)findViewById(R.id.driver); 
    driver.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View view) 
     { 
      Intent login=new Intent(MapsActivity.this,Driverlogin.class); 
      startActivity(login); 
     } 
    }); 
} 

@Override 
protected void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); 

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) 
    { 
     checkLocationPermission(); 
    } 
    // Obtain the SupportMapFragment and get notified when the map is ready to be used. 
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); init(); 
} 
関連する問題