title: Id is correct but - java.lang.NullPointerException: android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
body: <p>I'm having a trouble with NPE of setText() such a long time.<br>
  Some status in Tab1Fragment what I could see with below code:  </p>
  
  <ul>
  <li>textview is null.</li>
  <li>fullText got a ideal value. </li>
  </ul>
  
  <p>Am I missing any points? My only intention is to update TextView in Tab1Fragment from a listView in HomeFragment when it's clicked. (It seems like that's far ahead of me)<br>
  Thanks in advance.  </p>
  
  <p><strong>HomeFragment.java</strong></p>
  
  <pre><code>public class HomeListAdapter extends BaseAdapter {
          AddLawMap addLawMap = new AddLawMap();
          private final ArrayList&lt;String&gt; list;
          private Tab1Fragment tab1Fragment = new Tab1Fragment();
          private Tab2Fragment tab2Fragment = new Tab2Fragment();
          private Tab3Fragment tab3Fragment = new Tab3Fragment();
          private GetTextFragment getTextFragment = new GetTextFragment();
  
  ...
  
  @Override
          public View getView(int position, View convertView, ViewGroup parent){
              final View result;
  
              if(convertView == null){
                  result = LayoutInflater.from(parent.getContext()).inflate(R.layout.home_item, parent, false);
              }else{
                  result = convertView;
              }
  
              if(getCount() != 0) {
  
                  String itemId = getItem(position);
                  final TextView tv1 = result.findViewById(R.id.text_home_item);
                  tv1.setTag(itemId);
                  tv1.setText(addLawMap.getMapString().get(itemId));
  
                  result.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(final View view) {
                          final String tag = tv1.getTag().toString();
  
                          AlertDialog.Builder builder2 = new AlertDialog.Builder(mcontext);
                          builder2.setTitle(R.string.choose_fragment)
                                  .setItems(R.array.choose_fragment, new DialogInterface.OnClickListener() {
                                      @Override
                                      public void onClick(DialogInterface dialog, int which) {
                                          int duration = Toast.LENGTH_SHORT;
                                          Toast toast = Toast.makeText(mcontext, R.string.after_set_fulltext_toast, duration);
  
                                          switch (which) {
                                              case 0:
                                                  tab1Fragment.setFullText(getTextFragment.getFileStream(tag));
                                                  tab1Fragment.updateUi();
                                                  toast.show();
  
                                                  break;
                                              ...
                                          }
                                      }
                                  });
                          AlertDialog dialog2 = builder2.create();
                          dialog2.show();
                      }
                  });
                  return result;
  
              }else {
                  return result;
              }
          }
      }
  </code></pre>
  
  <p><strong>Tab1Fragment.java</strong></p>
  
  <pre><code>public class Tab1Fragment extends Fragment {
  
      private static final String ARG_COUNT = "param1";
      private Integer counter;
      private Handler mHandler = new Handler(Looper.getMainLooper());
      private String fullText;
      private int numSetText;
      private int numTab1;
      @NonNull TextView textView;
  
  
      @Override
      public void onAttach(Context context) {
          super.onAttach(context);
          Log.i("TAB1_FRAGMENT", "/onAttach");
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          if (getArguments() != null) {
              counter = getArguments().getInt(ARG_COUNT);
          }
           numTab1 = 0;
           numSetText = 0;
      }
  
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, Bundle savedInstanceState){
          super.onCreateView(inflater, container, savedInstanceState);
          Log.i("TAB1_FRAGMENT", "/onCreateView");
  
          return inflater.inflate(R.layout.fragment_tab1, container, false);
      }
  
      @Override
      public void onViewCreated(View view, Bundle savedInstanceState){
          super.onViewCreated(view, savedInstanceState);
          TextView textView = (TextView) getView().findViewById(R.id.tab1_textview);
  
          if(fullText == null){
              ImageView imageView = (ImageView) getView().findViewById(R.id.none_added);
              imageView.setVisibility(View.VISIBLE);
              textView.setVisibility(View.INVISIBLE);
          }else{
              textView.setText(fullText);
          }
          Log.i("TAB1_FRAGMENT", "/onViewCreated");
      }
  
      public void setFullText(String fullText){
          this.fullText = fullText;
          Log.i("TAB1_FRAGMENT", "/setFullText()");
          ++ numSetText;
      }
  
      public void updateUi(){
          if(fullText != null){
              mHandler.post(new Runnable() {
                  @Override
                  public void run() {
                      textView.setText(fullText);
                      ++numTab1;
                  }
              });
          }
      }
  
  
  
      @Override
      public void onPause() {
          super.onPause();
          Log.i("TAB1_FRAGMENT", "/onPause");
      }
  
      @Override
      public void onStart(){
          super.onStart();
          Log.i("TAB1_FRAGMENT", "/onStart");
      }
  
      @Override
      public void onResume(){
          super.onResume();
          Log.i("TAB1_FRAGMENT", "/onResume");
  
      }
  
      @Override
      public void onDetach(){
          super.onDetach();
          mHandler = null;
      }
  </code></pre>
  
  <p><strong>fragment_tab1.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;ImageView
          android:id="@+id/none_added"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:src="@drawable/tab_none_added"
          android:visibility="gone"/&gt;
  
          &lt;TextView
              android:id="@+id/tab1_textview"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:lineSpacingExtra="3dp"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Logcat</strong></p>
  
  <pre><code>2020-06-08 22:52:25.855 9668-9668/com.example.morina.mylaw I/TAB1_FRAGMENT: /setFullText()
  2020-06-08 22:52:25.881 9668-9668/com.example.morina.mylaw W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
  2020-06-08 22:52:25.882 9668-9668/com.example.morina.mylaw E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.morina.mylaw, PID: 9668
      java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
          at com.example.morina.mylaw.Tab1Fragment$1.run(Tab1Fragment.java:82)
          at android.os.Handler.handleCallback(Handler.java:790)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:164)
          at android.app.ActivityThread.main(ActivityThread.java:6494)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
  </code></pre>