How to display text in a TextView inside a Fragment

前端 未结 1 1774
没有蜡笔的小新
没有蜡笔的小新 2021-01-17 03:03

Seems like a simple question to me, but I can\'t figure it out. I have this code inside my Fragment:

myTextView.setText(\"Test\");

However,

1条回答
  •  醉梦人生
    2021-01-17 03:28

    How did you set the content?

    Edited my answer :) try this

     @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.xmlName,
            container, false);
        TextView tv= (TextView) **view**.findViewById(R.id.textViewName);
        tv.setText("yourText"); 
        return view;
      }
    

    here is a tutorial for fragments : fragments tutorial

    0 讨论(0)
提交回复
热议问题