1
votes

Here is my layout :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="1280dp"
    android:layout_height="800dp">


    <al.android.emcr.MainDisplay
        android:layout_width="1280dp"
        android:layout_height="800dp"/>
    <al.android.emcr.menu.MenuDisplay
        android:layout_width="1280dp"
        android:layout_height="114dp"/>

    <al.android.emcr.popups.ConfigurePopup.ConfigurePopup
        android:layout_width="1280dp"
        android:layout_height="800dp" />

</RelativeLayout>`

When I refresh my "MainDisplay" view with invalidate(), there's no problem. But when I try to do it with my MenuDisplay with the same method, the view is not refreshed. What am I doing wrong ?

Note: the both views have the "onDraw(Canvas)" method implemented.

Note2: I call the invalidate() method in the main thread. I'm wondering if the fact one of the views overlay the other has any wrong effect on the views refresh.

Note3: The onTouch() event work fine on both views.

1
what do u mean by refresh? what are you doing that needs refreshing?dor506
Once I've changed my content view, I want to display the new view !nonozor
kindly show some more code . currently the xml doesn't even have id for the views ...android developer

1 Answers

0
votes

Ok I solve my issue : in the MenuDisplay class I had two constructors :

public MenuDisplay(Context c, AttributeSet attrs) { super (c,attrs); init(c); }

and public MenuDisplay(Context c) { super(c); init(c); }

What it caused my problem it was that I called init(c) in both methods. I think, the best solution consists in call the init method in the native View method : onFinishInflate() with eventually a static counter to call init only for the last inflate occurence (if they are many inflates for the same view) !