Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get id in different layout

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

like image 511
bbkaaka Avatar asked Nov 18 '10 02:11

bbkaaka


1 Answers

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.

like image 156
Eddie Avatar answered Sep 23 '22 05:09

Eddie