我正在尝试引用片段中的图像按钮,但是遇到错误无法解析符号视图!我已经导入了View视图,但是错误仍然存在!有人可以帮忙清理一下!谢谢
public class ChildrensList extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.childrens_list,container,false);
return rootView;
ImageButton movedButton = (ImageButton) view.findViewById(R.id.movedButton);
pigsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(ChildrensList.this.getActivity(),downtown.class);
startActivity(i);
}
});
}
最佳答案
您的视图称为rootView
而不是view
。
而且您还返回了rootView。所以没有办法,任何进一步的陈述都是可以达到的。
关于java - 无法在Android Studio中解析符号“ View ”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36085908/