I only want to get an object from a xml layout file without having to implement it into the current layout.
I know the way with
LayoutInflater.from(context).inflate(R.layout.myfile, myparent, true);
but after execution of the above the layout will be implemented and shown immediately inside my "myparent"-View, right? I only want to get the Object itself to get its attributes and such. And maybe (but only maybe) insert it later into the shown layout.
Is that possible?
Regards
You should change your line to:
LayoutInflater.from(context).inflate(R.layout.myfile, null);
You can find it in documentation here.
LayoutInflater.from(context).inflate(R.layout.myfile, myparent, true);
The end parameter determines whether or not to automatically add the new view to myparent. Turn it to false to still use the parent's layout attributes.
Or, if you don't care about the parent's layout params, follow @inazaruk's answer
You could make this component invisible with:
android:visibility="gone"
Source:
http://developer.android.com/reference/android/view/View.html#attr_android:visibility