1. Are you ready for the Galaxy S20? Here is everything we know so far!

dev android studio .setvisibility not working

Discussion in 'Android Development' started by lichee, Mar 23, 2021.

  1. lichee

    lichee Lurker
    Thread Starter

    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()


    Code (Java):
    1. void gifs(){
    2.         if((int)(Ws) < 10){
    3.             goff.setVisibility(View.GONE);    // cutta gifview
    4.             ES1.setVisibility(View.VISIBLE);  // android-gif-drawable
    5.             Log.d("gifs","   "+goff.getVisibility() +"   ora "+goff.getGifResource());
    6.  
    7.         }else{
    8.             goff.setVisibility(View.VISIBLE);
    9.             ES1.setVisibility(View.GONE);
    10.             Log.d("gifs","   "+goff.getVisibility() +"   ora "+goff.getGifResource());
    11.  
    12.         }
    13.      
    14.  
    15.     }
    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


    Code (Java):
    1. public  class MainActivity extends AppCompatActivity {
    2.     public static pl.droidsonroids.gif.GifTextView giff,ES1,ES2,ES3,ES4,ES5,ES6;
    3.     public static GifView goff;
    4.     public static byte Ws;
    5.     public  SeekBar temp ;    
    6.  
    7.         protected void onCreate(Bundle savedInstanceState) {
    8.         SD=0;
    9.         super.onCreate(savedInstanceState);
    10.         setContentView(R.layout.activity_main);
    11.         getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    12.         ES1 = findViewById(R.id.es1);
    13.         ES2 = findViewById(R.id.es2);
    14.         ES3 = findViewById(R.id.es3);
    15.         ES4 = findViewById(R.id.es4);
    16.         ES5 = findViewById(R.id.es5);
    17.         ES6 = findViewById(R.id.es6);
    18.         goff = (GifView) findViewById(R.id.gif1);
    19.         ES1 = (pl.droidsonroids.gif.GifTextView) findViewById(R.id.es1);
    20.  
    21.      
    22.         temp= findViewById(R.id.tBar);
    23.         temp.setProgress(1);
    24.      
    25.  
    26.         temp.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
    27.             [USER=1021285]@override[/USER]
    28.  
    29.          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    30.                 progressChangedValue = progress;
    31.                 T[0]=(byte)progressChangedValue;
    32.                 Ws=(byte)progressChangedValue;
    33.                 tmp.setText(T[0]+" º");
    34.                 //graphsInit();
    35.                 //CriticalPointUpdate();
    36.                 D1[1]=progressChangedValue;
    37.             }
    38.  
    39.             [USER=1021285]@override[/USER]
    40.             public void onStartTrackingTouch(SeekBar seekBar) {
    41.             }
    42.  
    43.             [USER=1021285]@override[/USER]
    44.             public void onStopTrackingTouch(SeekBar seekBar) {
    45.                 Ws=(byte)progressChangedValue;
    46.                 gifs();
    47.                 D1[1]=progressChangedValue;
    48.                 T[0]=(byte)progressChangedValue;
    49.                 //graphsInit();
    50.                 //CriticalPointUpdate();
    51.                 D1[1]=progressChangedValue;
    52.                 Intent intent = new Intent(MainActivity.this, send.class);
    53.                 startActivity(intent);
    54.                 if(buffered[1]==1){
    55.                     vp1=buffered[3]*256+buffered[4];
    56.                     //Log.d("vp","vp1 = "+vp1+"   ");
    57.                 }
    58.  
    59.  
    60.             }
    61.         });
    62.  
    63.         try {
    64.             /* Open the serial port */
    65.             mSerialPort = new SerialPort(new File("/dev/ttyS2"), 9600, 0);
    66.             mOutputStream = mSerialPort.getOutputStream();
    67.             mInputStream = mSerialPort.getInputStream();
    68.  
    69.             mBuffer = new byte[128];
    70.             /* Create a receiving thread */
    71.             mReadThread = new ReadThread();/* Create a serial port receiving program */
    72.             mReadThread.start();
    73.  
    74.         } catch (SecurityException e) {
    75.             e.printStackTrace();
    76.         } catch (IOException e) {
    77.             e.printStackTrace();
    78.         }
    79.     }
    80.     }
    i removed other parts of the code because they are for other function like plotting and serial Comms


    XML of goff and ES1

    HTML:
    1. <com.cunoraz.gifview.library.GifView
    2. >     android:id="@+id/gif1"
    3. >     android:layout_width="wrap_content"
    4. >     android:layout_height="wrap_content"
    5. >     android:visibility="visible"
    6. >     android:layout_marginLeft="710dp"
    7. >     android:layout_marginTop="30dp"
    8. >     app:gif="[USER=22138]@Mipmap[/USER]/cuno" />
    9. >
    10. > <pl.droidsonroids.gif.GifTextView
    11. >     android:id="@+id/es1"
    12. >     android:layout_width="250dp"
    13. >     android:layout_height="500dp"
    14. >     android:layout_marginLeft="710dp"
    15. >     android:layout_marginTop="30dp"
    16. >     android:visibility="invisible"
    17. >     android:drawableStart="@drawable/es1" />
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...