• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

dev android studio .setvisibility not working

lichee

Lurker
Mar 23, 2021
1
0
hi i have an annoying problem with my application
i added a gif image using the droidondroids GifView and with that a seekbar i wanted either to change the ressource of the gif image according to the seek bar no luck goff.setvisibility(View.GONE/VISIBLE/INVISIBLE) not working the first it works but none after it i have a func named gifs()


Java:
void gifs(){
        if((int)(Ws) < 10){
            goff.setVisibility(View.GONE);    // cutta gifview
            ES1.setVisibility(View.VISIBLE);  // android-gif-drawable
            Log.d("gifs","   "+goff.getVisibility() +"   ora "+goff.getGifResource());

        }else{
            goff.setVisibility(View.VISIBLE);
            ES1.setVisibility(View.GONE);
            Log.d("gifs","   "+goff.getVisibility() +"   ora "+goff.getGifResource());

        }
     

    }
i have the Ws value from the seekbar onstopTracking() and the func gifs() there too
as you can see i'm logging with Log.d and the .getVisibility() is returning that the goff is changing value but nothing on the UI

i also tried with maybe goff.setGifResource(R.drawable.es6);

my goal is to show
1-either multiple gifs but one at a time (gifs with different speed )
2- the same view but change the ressource to multiple gifs speeds


here is the code and declarations


Java:
public  class MainActivity extends AppCompatActivity {
    public static pl.droidsonroids.gif.GifTextView giff,ES1,ES2,ES3,ES4,ES5,ES6;
    public static GifView goff;
    public static byte Ws;
    public  SeekBar temp ;     

        protected void onCreate(Bundle savedInstanceState) {
        SD=0;
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        ES1 = findViewById(R.id.es1);
        ES2 = findViewById(R.id.es2);
        ES3 = findViewById(R.id.es3);
        ES4 = findViewById(R.id.es4);
        ES5 = findViewById(R.id.es5);
        ES6 = findViewById(R.id.es6);
        goff = (GifView) findViewById(R.id.gif1);
        ES1 = (pl.droidsonroids.gif.GifTextView) findViewById(R.id.es1);

     
        temp= findViewById(R.id.tBar);
        temp.setProgress(1);
     

        temp.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            [USER=1021285]@override[/USER]

         public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                progressChangedValue = progress;
                T[0]=(byte)progressChangedValue;
                Ws=(byte)progressChangedValue;
                tmp.setText(T[0]+" º");
                //graphsInit();
                //CriticalPointUpdate();
                D1[1]=progressChangedValue;
            }

            [USER=1021285]@override[/USER]
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            [USER=1021285]@override[/USER]
            public void onStopTrackingTouch(SeekBar seekBar) {
                Ws=(byte)progressChangedValue;
                gifs();
                D1[1]=progressChangedValue;
                T[0]=(byte)progressChangedValue;
                //graphsInit();
                //CriticalPointUpdate();
                D1[1]=progressChangedValue;
                Intent intent = new Intent(MainActivity.this, send.class);
                startActivity(intent);
                if(buffered[1]==1){
                    vp1=buffered[3]*256+buffered[4];
                    //Log.d("vp","vp1 = "+vp1+"   ");
                }


            }
        });

        try {
            /* Open the serial port */
            mSerialPort = new SerialPort(new File("/dev/ttyS2"), 9600, 0);
            mOutputStream = mSerialPort.getOutputStream();
            mInputStream = mSerialPort.getInputStream();

            mBuffer = new byte[128];
            /* Create a receiving thread */
            mReadThread = new ReadThread();/* Create a serial port receiving program */
            mReadThread.start();

        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    }

i removed other parts of the code because they are for other function like plotting and serial Comms


XML of goff and ES1

HTML:
<com.cunoraz.gifview.library.GifView
>     android:id="@+id/gif1"
>     android:layout_width="wrap_content"
>     android:layout_height="wrap_content"
>     android:visibility="visible"
>     android:layout_marginLeft="710dp"
>     android:layout_marginTop="30dp"
>     app:gif="[USER=22138]@Mipmap[/USER]/cuno" />
>
> <pl.droidsonroids.gif.GifTextView
>     android:id="@+id/es1"
>     android:layout_width="250dp"
>     android:layout_height="500dp"
>     android:layout_marginLeft="710dp"
>     android:layout_marginTop="30dp"
>     android:visibility="invisible"
>     android:drawableStart="@drawable/es1" />
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones