i have been creating an App that uses Fragments Mostly here is how it is supposed to work, on the Home Fragment i click a button that takes me to another Fragment for filling information on this fragment when I click a button a Dialog Fragment opens and I select a City Name then Submit, it dismisses the Dialog and is supposed to SetText on a TextView.
I use an interface that calls a method on the City Selection fragment in order to set the Text. here is some Code
Declaration for the EditText
EditText editText_From;
Setting finding the View
OnCreate
   @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState)
    {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_trip_date, container, false);
        editText_From = view.findViewById(R.id.editText_From);
        return view;
    }
       public void setSelectedCity(String city)
{
    Log.i("<<269>>", "Setting Text on Edit Text <<269>>:" + city);
   editText_From.setText(city);
}
This Method below is supposed to set text for the my EditText or TextView
    public void setSelectedCity(String city)
{
    Log.i("<<269>>", "Setting Text on Edit Text <<269>>:" + city);
    selectedCityConfirmed = city;
   editText_From.setText(city);
}
the App Crashes on EditText with the Following Error Message,
02-16 19:37:43.928 26582-26582/com.example.bob2609.busticketingapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.bob2609.busticketingapp, PID: 26582
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.support.v4.app.FragmentActivity.findViewById(int)' on a null object reference
        at com.example.bob2609.busticketingapp.TripDateFragment.setSelectedCity(TripDateFragment.java:188)
        at com.example.bob2609.busticketingapp.MainActivity.selectedCity(MainActivity.java:176)
        at com.example.bob2609.busticketingapp.LocationSelector$1.onItemClick(LocationSelector.java:69)
        at android.widget.AdapterView.performItemClick(AdapterView.java:313)
        at android.widget.AbsListView.performItemClick(AbsListView.java:1201)
        at android.widget.AbsListView$PerformClick.run(AbsListView.java:3195)
        at android.widget.AbsListView$3.run(AbsListView.java:4138)
        at android.os.Handler.handleCallback(Handler.java:761)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:156)
        at android.app.ActivityThread.main(ActivityThread.java:6523)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
The Interface Method on MainActivity
  @Override
public void selectedCity(String city)
{
    tripDateFragment.setSelectedCity(city);
}
Anyone knows a way around this?

 
     
    