2012-04-02 12 views
1

私はウェブから曲をストリーミングするために取り組んでいます。 Customized Seek Barを作成しましたが、アプリケーションでセカンダリプログレスバーを設定できません。私は自分のコードを添付しています。私が間違いを犯した可能性がある場所を教えてください。カスタマイズされたSeekBarのセカンダリ進捗状況を設定中に

これは私のcustom_seek_bar.xmlです:

<?xml version="1.0" encoding="UTF-8"?> 

<layer-list 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<item 
    android:id="@android:id/background"> 
    <shape> 
     <corners 
      android:radius="10dip" /> 
     <stroke 
      android:width="4dip" 
      android:color="#ff000000" /> 
     <gradient 
      android:startColor="#ff734B35" 
      android:centerColor="#ff8A6249" 
      android:centerY="0.50" 
      android:endColor="#ff91694F" 
      android:angle="270" /> 
    </shape> 
</item> 
<item 
    android:id="@android:id/secondaryProgress"> 
    <clip> 
     <shape> 
      <corners 
       android:radius="10dip" /> 
      <stroke 
      android:width="4dip" 
      android:color="#ff000000" /> 
      <gradient 
       android:startColor="#ff734B35" 
       android:centerColor="#ff8A6249" 
       android:endColor="#ff91694F" 
       android:angle="270" /> 
     </shape> 
    </clip> 
</item> 
<item 
    android:id="@android:id/progress"> 
    <clip> 
     <shape> 
      <corners 
       android:radius="10dip" /> 
      <stroke 
      android:width="4dip" 
      android:color="#ff000000" /> 
      <gradient 
       android:startColor="#432011" 
       android:endColor="#ff4A2514" 
       android:angle="90" /> 
     </shape> 
    </clip> 
</item> 

これは私のstyles.xmlです:

<style name="CustomSeekBar" parent="android:Widget.SeekBar"> 
     <item name="android:progressDrawable">@drawable/custom_seek_bar</item> 
     <item name="android:thumbOffset">0dip</item> 
</style> 

私はplaying.xmlでそれを宣言した:

<SeekBar 
      android:id="@+id/seekBar1" 
      style="@style/CustomSeekBar" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="17dp" 
      android:layout_marginRight="15dp" 
      android:secondaryProgress="100" 
      android:thumb="@drawable/point" /> 
私はエラーを取得していないすべてのこの後

SeekBar songControl, songControl1; 
songControl = (SeekBar) view.findViewById(R.id.seekBar1); 
songControl.setEnabled(false); 
txt_Timer = (TextView) view.findViewById(R.id.text_start_time); 
txt_stop_timer = (TextView) view.findViewById(R.id.text_stop_time); 
songControl.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { 

     @Override 
     public void onStopTrackingTouch(SeekBar seekBar) { 
      // TODO Auto-generated method stub 

     } 

     @Override 
     public void onStartTrackingTouch(SeekBar seekBar) { 
      // TODO Auto-generated method stub 

     } 

     @Override 
     public void onProgressChanged(SeekBar seekBar, int progress, 
       boolean fromUser) { 
      // TODO Auto-generated method stub 

      Log.d("Progres changed", "" + progress); 

      try { 

       if (mediaPlayer.isPlaying()) { 
        int seconds = (int) (progress/1000) % 60; 
        int minutes = (int) ((progress/(1000 * 60))); 
        txt_Timer.setText("" + minutes + ":" + seconds); 
        if (fromUser) { 
         mediaPlayer.seekTo(progress); 
         songControl.setProgress(progress); 

        } 
       } else 
        songControl.setProgress(progress); 

      } catch (Exception e) { 
       // TODO: handle exception 
       e.printStackTrace(); 
      } 

     } 
    }); 
@Override 
public void onBufferingUpdate(MediaPlayer mp, int percent) { 
    // TODO Auto-generated method stub 
    Log.i("Main Activity", "Progress" + percent); 

    songControl.setSecondaryProgress(percent); 
    songControl.setBackgroundColor(Color.BLUE); 
} 

が、私はSeekBarにおける二次プログレスバーを取得していない曲を再生しながら:210

これは私のJavaファイルです。問題がCustom_seek_bar.xmlにあると思われますが、間違っていることはわかりません。

答えて

1

xmlにエラーはありません。セカンダリ進捗バーのcolorがバックグラウンドと同じであるために表示されませんでした。だから、あなたが望むものを得るために、あなたの背景やセカンダリープログレスカラーを変えてください!

関連する問題