如何让不同的布局ID [英] how to get id in different layout
本文介绍了如何让不同的布局ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 ID@ +用户ID /呼叫
在 single_item.xml
当我使用 findVewById
它(布局 setcontextview(R.layout.main)
).the应用程序崩溃。如何修正这个错误
i have id "@+id/call"
in single_item.xml
when i use findVewById
it (the layout setcontextview(R.layout.main)
) .the app crash .how to fix the error
推荐答案
您正在努力寻找一个视图(R.id.call)即宣布R.layout.single_item在layour R.layout.main,所以我估计是抛出一个空指针异常。
You are trying to find a View (R.id.call) that is declared in R.layout.single_item in the layour R.layout.main, so I guess it is throwing a Null Pointer Exception.
您应该要么宣布在main.xml中的文件@ +用户ID /呼叫的元素,或上下文视图设置为R.layout.single_item
You should either declare your "@+id/call" element in your main.xml file, or set the context view to R.layout.single_item
这篇关于如何让不同的布局ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文