onCreate是指创建该fragment类似于Activity.onCreate,
你可以在其中初始化除了view之外的东西,onCreateView是创建该fragment对应的视图
,你必须在这里创建自己的视图并返回给调用者,例如
return inflater.inflate(R.layout.fragment_settings, container, false);。
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {View view = inflater.inflate(R.layout.fragment_status, container,false);editStatus=(EditText)view.findViewById(R.id.editStatus);buttonTweet=(Button)view.findViewById(R.id.buttonTweet);textCount=(TextView)view.findViewById(R.id.textCount);defaultTextColor = textCount.getTextColors().getDefaultColor();buttonTweet.setOnClickListener(this);editStatus.addTextChangedListener(new TextWatcher() {@Overridepublic void onTextChanged(CharSequence s, int start, int before, int count) {// TODO Auto-generated method stub}@Overridepublic void beforeTextChanged(CharSequence s, int start, int count,int after) {}@Overridepublic void afterTextChanged(Editable s) {int count = 140-editStatus.length();textCount.setText(Integer.toString(count));textCount.setTextColor(Color.GREEN);if(count<10){textCount.setTextColor(Color.RED);}else{textCount.setTextColor(defaultTextColor);}}});return view;}