Issue
i am trying to get a refernce to an image button in my fragment but coming accross with an error cannot resolve symbol view! i have imported View view but the erro is still there! can someone help clear this up! thank you
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);
}
});
}
Solution
your view is called rootView
not view
.
And also you're returning rootView. So there's no way, any of the further statements would be reachable.
Answered By - zEro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.