我怎么能做出的setText在我的TextView从字符串“‘view.find ..’我不能用”我的片段布局

问题描述 投票:0回答:2

您好每一个我想从共享偏好文件中设置的文本串在我的片段布局文本视图,但是当我试图从共享偏好文件数据,并把它串和串由一组文本到文本视图我所面临的问题空像值指针i红粉他是空怎能ID是什么?

fragment.Java

fragment.xml之

enter image description here

logcat的错误

enter image description here

android android-studio android-fragments view nullpointerexception
2个回答
3
投票
View view = inflater.inflate(R.layout.fragment_home, container,false)

您在fragment_profile强似fragment_home。

只要改变它fragment_profile:

View view = inflater.inflate(R.layout.fragment_profile, container,false)

0
投票

在ProfileFragment.java R.layout.fragment_home更换你R.layout.fragment_profile

错误原因:

您在fragment_home膨胀ProfileFragment.java XML布局,并试图从textview访问fragment_profile部件

© www.soinside.com 2019 - 2024. All rights reserved.