无法在Android Studio中从一个活动更改为另一个页面(页面重新加载)

无法在Android Studio中从一个活动更改为另一个页面(页面重新加载)

问题描述:

在按下一个按钮后重新加载相同的活动,该按钮用于其他活动,但在第一次执行时工作正常。代码是非常正常和基本的,但不能知道问题无法在Android Studio中从一个活动更改为另一个页面(页面重新加载)

public void init(){ImageButton driver =(ImageButton)findViewById(R.id.driver); (新视图.OnClickListener(){@Override public void onClick(View view){Intent login = new Intent(MapsActivity.this,Driverlogin.class); startActivity(login);}}); } @Override保护无效的onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);的setContentView(R.layout.activity_maps); (android.os.Build.VERSION.SDK_INT> = Build.VERSION_CODES.M){checkLocationPermission(); } //获取SupportMapFragment并在地图准备好使用时得到通知。 SupportMapFragment mapFragment =(SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(本);在里面(); }

+0

我们希望看到'code is normal and basic' this。此外,如果你有错误日志分享他们 –

+0

@shashi sekhar请添加您的正常和基本代码 – nomag

+0

更新我的问题,请检查。 –

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(); 
}