我已经动态地将一个片段添加到另一个片段。
我需要在该片段中找到一些视图。
我如何实现这一目标?
这是我的代码:
Select A.ID
,A.Amount
,RunningTotal = sum(B.Amount)
From @YourTable A
Join @YourTable B on (B.ID <=A.ID and B.ID between 6 and 9)
Where A.ID between 6 and 9
Group By A.ID,A.Amount
Order By A.ID
我想在Dynamic片段中找到这些视图:
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment_educational, container, false);
if (view != null)
{
ButterKnife.inject(this, view);
}
DisposableEducationalFragment disposableEducationalFragment = new DisposableEducationalFragment();
getChildFragmentManager().beginTransaction().add(R.id.fragmentContainer,disposableEducationalFragment).addToBackStack(null).commit();
答案 0 :(得分:0)
因此,将View view
保存到临时变量中,稍后再调用它。
tmpView = view;
以后某个地方:
howItWorks = (RelativeLayout) tempView.findViewById(R.id.HowItWorks);
或者,可能只是尝试一下:
howItWorks = (RelativeLayout) getActivity().findViewById(R.id.HowItWorks);