Reputation: 4691
Hi i am getting a StackOverflow error while trying to add a view in layout.
Code:
parentOfAllInGMT.addView(layoutInflater.inflate(
R.layout.layout_dstbutton, parentOfAllInGMT, true));
here parentOfAllInGMT is a Linear Layout and i want layout_dstbutton
to be the child at index 1.
Prior to adding layout_dstbutton
, i added
parentOfAllInGMT.addView(layoutInflater.inflate(
R.layout.gmt_option_list_dst_on, null, false));
which is adding properly.
Following is logcat output:
08-06 07:23:44.843: E/AndroidRuntime(19513): java.lang.StackOverflowError
08-06 07:23:44.843: E/AndroidRuntime(19513): at android.view.View.isLayoutDirectionInherited(View.java:11756)
08-06 07:23:44.843: E/AndroidRuntime(19513): at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5379)
08-06 07:23:44.843: E/AndroidRuntime(19513): at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5380)
08-06 07:23:44.843: E/AndroidRuntime(19513): at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5380)
08-06 07:23:44.843: E/AndroidRuntime(19513): at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5380)
08-06 07:23:44.843: E/AndroidRuntime(19513): at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5380)
Upvotes: 1
Views: 4665
Reputation: 4691
The root cause of the problem was design/approach i was taking.
I was using gmt_option_list_dst_on
which had 34 relative layout, and within each layout i had 5 views. So they all sum up and made a total of 170 views, most probably that was reason reason for stackoverflow exception.
So i choose a customize listview instead of inflating multiple(170) views. Listview allowed me easy way to handle event and performance was enhanced too.
Upvotes: 4