Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - problem with RelativeLayout children with GONE visibility
    primarykey
    data
    text
    <p>Here the sample code:</p> <pre><code> public class CustomImageVIew extends LinearLayout { private Image mImage = null; private ImageView mImageView; private ProgressBar mProgressBar; private RelativeLayout mLayout; public static enum State {NOT_LOADED, IMAGE_LOADING, IMAGE_LOADED}; private State state; public CustomImageVIew(Context context) { this(context, null); } public CustomImageVIew(Context context, AttributeSet attrs) { super(context, attrs); View v = View.inflate(getContext(), R.layout.gallery_image_view, null); mLayout = (RelativeLayout) v; addView(mLayout); mImageView = (ImageView) mLayout.findViewById(R.id.gallery_image_view_image); mProgressBar = (ProgressBar) mLayout.findViewById(R.id.gallery_image_view_progress_bar); setState(State.NOT_LOADED); } private void setState(State newState) { if (state != newState) { state = newState; switch (state) { case NOT_LOADED: mImageView.setVisibility(View.GONE); mProgressBar.setVisibility(View.GONE); break; case IMAGE_LOADING: mImageView.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.VISIBLE); break; case IMAGE_LOADED: mImageView.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.GONE); break; } } } public State getState() { return state; } } &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ImageView android:id="@+id/gallery_image_view_image" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;ProgressBar style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:id="@+id/gallery_image_view_progress_bar" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_centerHorizontal="true" android:clickable="false"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>When i call setState(State.IMAGE_LOADED) outside of onCreate method nothing happens. What problem can it be ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload