How to access parent Activity View in Fragment
You can use
View view = getActivity().findViewById(R.id.viewid);
Quoting docs
Specifically, the fragment can access the Activity instance with getActivity() and easily perform tasks such as find a view in the activity layout
At first, create a view like this:
View view = getActivity().findViewById(R.id.viewid);
Then convert it to any view that you need like this:
if( view instanceof EditText ) {
editText = (EditText) view;
editText.setText("edittext");
//Do your stuff
}
or
if( view instanceof TextView ) {
TextView textView = (TextView) view;
//Do your stuff
}
In Kotlin it is very easy to access parent Activity View in Fragment
activity!!.textview.setText("String")