Let's say I have a custom view:
<com.xx.xx.xx.CustomView
android:id="@+id/customView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="doAction"/>
Then in my Activity I have:
public void doAction(View v) {
if(customView == null) customView = (CustomView) v;
... do stuff
}
So as you can see, first time I click the view, I retrieve it and store it in an Activity field. Then I can use it anywhere. With this, I don't need to use findViewById.
I have to questions:
- Is this more performant or is the same?
- Is this a correct way to go?
Many thanks!