Search code examples
androidviewoverridingonmeasure

Interrupting the onMeasure cycle to display an error (Android)


I've overriden the getView(int, View, ViewGroup) method of View to provide some custom behaviour and I'd like to be able to abort the recursive measure() -> onMeasure() -> measureChildStuff() -> child.measure() if an error occurrs during my custom getView() call, and immediately stop trying to render that Activity in favour of another that shows the error.

Unfortunately, it seems Android insists on finishing the stack of measuring before listening to my Intent to change the Activity. Is there a way I can force an Intent to be immediately started? For example, could I achieve anything by overriding Context.startActivity()?


Solution

  • If you set visibility to View.GONE, layout will skip that view.