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
If you want to access a view in another layout (not the active layout), then you can inflate the layout you want to use and access it that way.
Example:
View inflatedView = getLayoutInflater().inflate(R.layout.other_layout, null);
TextView text = (TextView) inflatedView.findViewById(R.id.text_view);
text.setText("Hello!");
More information about inflating layouts can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With