Reputation: 185
l have an object that can contain any type of layout. How can I detect layout type ? I have an idea only with try/catch.
Upvotes: 0
Views: 56
Reputation: 9761
Example:
final ViewGroup layout = yourObject.getMyLayout();
if (layout instanceof LinearLayout) {
//do something
}
else if (layout instanceof TableLayout){
// do something else
}
Upvotes: 1
Reputation: 961
Little bit clunky but you could have an if statement like this
if(this.getCurrentFocus().getId() == R.layout.myLayout)
{
String layoutType = "Linear";
}
or do whatever you need to with the result
Upvotes: 0