【问题标题】:Move From one FragmentActivity to other Class?从一个 FragmentActivity 移动到另一个类?
【发布时间】: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


    【解决方案1】:
    1. 片段是活动的一部分。你不能这样移动。您可以在 tablayout 、bottomnavgrafh 等上使用它们。
    2. 如果要使用片段,请使用导航图或选项卡布局

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-06
      • 1970-01-01
      • 1970-01-01
      • 2011-07-06
      • 1970-01-01
      相关资源
      最近更新 更多