Submit Post - Article - Ask a Question - Ask an Interview Question - Submit Useful Links

findviewbyid in fragment

I have created a fragment with some controls ,so the issue is that i want to find these controls for manuplate some  value ,how i can get these controls

By      08-Dec-2023    2

Solutions


Nawab

you can find these controls as below on onViewCreated

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    textview tv= (textview ) getView().findViewById(R.id.tv);

OR

View view = inflater.inflate(R.layout.testclassfragment, container, false);
      textview tv==  view.findViewById(R.id.tv); 
     return view;

Your Answer

10041
Submit Post - Article - Ask a Question - Ask an Interview Question - Submit Useful Links