在……里面
override fun pastDada(name: String) {
val bundle = Bundle()
bundle.putString("USER_NAME", "DDDDDDDD")
val transction = this.supportFragmentManager.beginTransaction()
val profileFragmant = fragment_profile()
profileFragmant.arguments = bundle
transction.replace(R.id.container,profileFragmant)
}
在Frafment:
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
var view = inflater.inflate(R.layout.fragment_profile2, container, false)
name = arguments?.getString("USER_NAME")
Log.e("name", arguments?.getString("USER_NAME").toString())
Log.e("name", name.toString())
view.tv_name.text = name
return view
}
E(“name”,name.toString())的结果总是空的,我不知道为什么maby因为我的参数是空的?如果是的话,我该如何去解决它呢?
谢谢
1条答案
按热度按时间8hhllhi21#
如下所示更改代码