【发布时间】:2022-01-10 22:42:29
【问题描述】:
我有两个类名称 LocationPicker_2 和 LocationPicker 都用 FragmentActivity 扩展,所以我想从 LocationPicker_2 移动到 LocationPicker,我使用了简单启动活动,但它在点击时不起作用。enter image description here
public class LocationPicker_2 extends FragmentActivity implements OnMapReadyCallback
{@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_location_picker2);
supportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
supportMapFragment.getMapAsync(this);
from = findViewById(R.id.editTextFrom);
Places.initialize(getApplicationContext(),"AIzaSyCIwPlfTKNCGDcoMuOWwNTTyG5tnI_MyqM");
from.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
field = Arrays.asList(Place.Field.ADDRESS,Place.Field.NAME,Place.Field.LAT_LNG);
Intent intent = new Autocomplete.IntentBuilder(AutocompleteActivityMode.OVERLAY,field).build(LocationPicker_2.this);
startActivityForResult(intent,place_picker_req_code);
switch(v.getId()){
case R.id.imageViewbfrom:
startActivity(new Intent(LocationPicker_2.this,LocationPicker.class));
break;
case R.id.NexttbtnLP2:
startActivity(new Intent(LocationPicker_2.this,Selectdate.class));
}
}
});
}
【问题讨论】:
标签: java android xml fragment android-fragmentactivity