android - Change a WebView Gif programmatically via spinner selection -
I put a web villa in one piece to show a gif animation. It works entirely webbie class:
public class GifWebView view {Private Movie mmv; InputStream is; Long MovStart; Public GifWebView (Reference Reference, String gifName) {Super (Reference); Paint P = new paint (); P.setAntiAlias (true); SetLayerType (LAYER_TYPE_SOFTWARE, P); If (gifName.startsWith ("acqua")) {= reference is. GetResources () OpenRawResource (R.drawable.water); } And if (gifName.startsWith ("aria")) {is = reference. GetResources () OpenRawResource (R.drawable.air); } MMovie = Movie. DecodeStream (is); } Draw over @ Override protected void (canvas canvas) {canvas entry color (color. WHITE); Super.onDraw (canvas); Longer = android.os.SystemClock.uptimeMillis (); //System.out.println("now="+now); If (moviestart == 0) {// moviestart = now for the first time; } //System.out.println("ttmoviestart="+moviestart); Int relatim = (int) ((now - možistart)% mMovie.duration ()); //System.out.println("time = "+ relTime +" \ treltime = "+ movie.duration ()); MMovie.setTime (relTime); MMoviekdraw (canvas, (boat) this.getWidth () / (float) mMovie.width (), (boat) this.getHeight () / (float) mMovie.height ()); This.invalidate (); }}
When I want to stop the GI animation and change it to another GIF by spinner selection in my piece:
mySpinner.setOnItemSelectedListener (new OnItemSelectedListener () {@Override public void onItemSelected (AdapterView & LT ;? & gt; parent, views, Int position, long id) {int posit = parent.getSelectedItemPosition (); PertSpinner .setPopupBackgroundResource (R.color.white); pertSpinner.setValConfirmed (with ); List (see approval) {case 0: toplayout.removeAllViewsInLayout (); view = new GifWebView (getActivity (), "acqua"); toplayout.addView (see); break; case 1: toplayout.removeAllViewsInLayout (); = New GifWebView (getActivity (), "aria"); toplayout.addView (see); breakdown;}} @OtherRide Nothing selected at public zero (adapter view & lt ;? & Gt; Parents) {// other interfaces callback}}); And GIF:
The app does not change the default GIF with this code. ? Any help will be apreciated !!
solution:
list (Pojit) {case 0: toplayout .removeAllViewsInLayout (); See = new GifWebView (getActivity (), "aria"); Toplayout.addView (see); Toplayout.setVisibility (View.VISIBLE); break; Case 1: toplayout.removeAllViewsInLayout (); See = new GifWebView (getActivity (), "acqua"); Toplayout.addView (see); break; }
Comments
Post a Comment