簡體   English   中英

我如何在當前進度內更改圖像的android seekbar拇指

[英]how can i change the android seekbar thumb of image within current progress

我是android的新手...正在創建seekbar ...我想更改圖像的拇指每個進度值...但是當我移動拇指時,它更改了圖像的拇指,但是它開始了搜尋欄。 有沒有人有解決方案,以隨着搜索欄進度移動不同的圖像?

這是我的代碼

    final Drawable thumb1 = getResources().getDrawable( R.drawable.one);
    final Drawable thumb2 = getResources().getDrawable( R.drawable.two);
    final Drawable thumb3 = getResources().getDrawable( R.drawable.three);
    final Drawable thumb4 = getResources().getDrawable( R.drawable.four);



    thumb1.setBounds(new Rect(0, 0, thumb1.getIntrinsicWidth(),thumb1.getIntrinsicHeight()));
    thumb2.setBounds(new Rect(0, 0, thumb2.getIntrinsicWidth(),thumb2.getIntrinsicHeight()));
    thumb3.setBounds(new Rect(0, 0, thumb3.getIntrinsicWidth(),thumb3.getIntrinsicHeight()));
    thumb4.setBounds(new Rect(0, 0, thumb4.getIntrinsicWidth(),thumb4.getIntrinsicHeight()));


             seekbar1.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress,
                    boolean fromUser) {


                 if(progress==0){
                    seekbar1.setThumb(thumb1);
                                //  seekbar1.setProgress(0);
                   }
                   else if(progress==1){
                            seekbar1.setThumb(thumb2);
                                //  seekbar1.setProgress(1);
                   }
                   else if(progress==2){
                    seekbar1.setThumb(thumb3);
                            //   seekbar1.setProgress(2);

                   }
                   else if(progress==3){                    
                                seekbar1.setThumb(thumb4);
                               //   seekbar1.setProgress(3);
                   }


            }

遵循本指南
http://javandroidevelop.blogspot.in/2012/09/cool-seekbar-custom-made-by-me.html
由於您是新手,所以建議您不要問這樣的問題並閱讀
https://stackoverflow.com/about
第一。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM