how to get id in different layout
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.