findViewById()在滑动导航抽屉中返回null值

时间:2016-04-16 11:31:07

标签: android

我在导航抽屉的滑动xml中有textview,当我试图访问textview时,它在findviewId给我空指针错误有人能告诉我如何访问它吗?我正在尝试使用它,但我无法这样做.....

function composeObj(objs, ...rest){
  return Object.assign(...rest);
}

1 个答案:

答案 0 :(得分:2)

替换此

 txtUserName.findViewById(R.id.txtUserName);
 txtUserDob.findViewById(R.id.txtUserDob);
 txtUserPlace.findViewById(R.id.txtUserLocation);

用这个

 txtUserName =  (TextView)findViewById(R.id.txtUserName);
 txtUserDob = (TextView)findViewById(R.id.txtUserDob);
 txtUserPlace = (TextView)findViewById(R.id.txtUserLocation);
相关问题