我的应用程序中的一个项目是导致另一个活动的选项。好的,我可以将此选项发送给其他活动,但我必须阅读该选项,然后根据此信息从布局中隐藏一些内容。
我已将此添加到 onCreate 方法中,但没有成功:
Bundle extras = getIntent().getExtras();
String type = extras.getString("objects");
if(type == "animals"){
ImageView fieldSwamp = (ImageView) findViewById(R.id.btnSwamp);
((LinearLayout)fieldSwamp.getParent()).removeView(fieldSwamp);
ImageView fieldGrass = (ImageView) findViewById(R.id.btnGrass);
((LinearLayout)fieldGrass.getParent()).removeView(fieldGrass);
}
然后我在“onLocationChanged”方法上尝试了它,但也没有成功。我不确定问题出在代码本身还是我放的地方。有人可以帮忙吗?
提前致谢!