I do not understand anything. Now I read the documents on the Android developers site and it says that in order to communicate with fragments I have to implement an interface. However, now I can easily access widgets that exist on the fragment in the Main activitiy class.
For example, in the main activity class, by issuing the following line, I can access the text element of the fragment.
TextView t1 = (TextView) findViewById(R.id.t1);
In this state, why do I need to implement an interface? (forgive my ignorance and thanks)
Fragment, Activity, ? getActivity(), , Activity, .
Fragment
Activity
getActivity()
, Java, , Activity, , , , MyActivity, , , Activity ActionBarActivity. ((MyActivity)getActivity()).myMethod();
MyActivity
ActionBarActivity
((MyActivity)getActivity()).myMethod();
, . , , MyActivity.
, myMethod() interface Activity . Activity, , , .
myMethod()
interface