我有一个片段查看器的主要活动。主要活动从其他活动中获取附加内容,并应将这些附加内容设置为地图片段的参数。
但是,在fra.setArguments(message);行上;该片段不存在,导致应用程序崩溃。
您能帮我解决吗?
public class MainScreen extends AppCompatActivity implements
listFragment.SendMessage {
private Toolbar mToolbar;
private ViewPager mViewpager;
private PageAdapter mPageAdapter;
private TabLayout mTablayout;
public Bundle message;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
mToolbar = (Toolbar) findViewById(R.id.mainToolbar);
mViewpager = (ViewPager) findViewById(R.id.tabsViewPager);
mTablayout = (TabLayout) findViewById(R.id.allTabs);
setSupportActionBar(mToolbar);
mPageAdapter = new PageAdapter(getSupportFragmentManager());
mViewpager.setAdapter(mPageAdapter);
mTablayout.setupWithViewPager(mViewpager);
if(getIntent().getExtras()!= null) {
message = new Bundle();
message.putDouble("Lat",getIntent().getBundleExtra("Bundle").getDouble("Lat",0));
message.putDouble("Long",getIntent().getBundleExtra("Bundle").getDouble("Long",0));
String tag = "android:switcher:" + R.id.tabsViewPager + ":" + 0;
mapFragment fra = (mapFragment) getSupportFragmentManager().findFragmentByTag(tag);
fra.setArguments(message);
}
}