我的项目中有4个片段,每个片段都有一个微调器。
每次点击/切换片段时,微调器数据/值都会重复多次。每个微调器/片段具有相同的相应内容和值。
**--NOT TAP/FIRST LOAD--**
SUN
PLANET
STARS
COMET
**--TAP TWO OR MORE TIMES--**
SUN
PLANET
STARS
COMET
**SUN - data is repeated twice
**PLANET
**STARS
**COMET
***SUN - data is repeated thrice
***PLANET
***STARS
***COMET
我错过了什么吗?片段是多次调用的吗?
这是我的代码:
public class SolarSystem1 extends Fragment { - first fragment
public class SolarSystem2 extends Fragment { - second fragment
public class SolarSystem3 extends Fragment { - third fragment
public class SolarSystem4 extends Fragment { - fourth fragment
-----and so on-----
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View myFragmentView = inflater.inflate(R.layout.activity_view, container, false);
txtSystem = (Spinner) myFragmentView.findViewById(R.id.system);
system_options.add("SUN");
system_options.add("PLANET");
system_options.add("STARS");
system_options.add("COMETS");
ArrayAdapter<String> systemAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item,system_options);
systemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
systemAdapter.setNotifyOnChange(true);
txtSystem.setAdapter(systemAdapter);
希望你能帮助我。