Je cherchais à changer les couleurs de ma seekbar mais j'ai une erreur :
no resources found that match the given name. L'erreur est sur @drawable/custom_progress_bar_horizontal dans styles.xml
Mon code :
le main.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package aa.bb; import android.app.Activity; import android.os.Bundle; import android.widget.SeekBar; public class Essai extends Activity{ SeekBar mSeekBar; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mSeekBar = (SeekBar)findViewById(R.id.seekBar1); } }
et style.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <SeekBar android:id="@+id/seekBar1" android:layout_width="256dp" android:layout_height="wrap_content" android:max="80" android:paddingLeft="20px" style="@style/MyCustomProgressStyle" /> <!-- android:progressDrawable="@+drawable/custom_progress_bar_horizontal" --> </LinearLayout>
J'ai bien rajouté un fichier custom_progress_bar_horizontal.xml dans le dossier drawable. Je ne comprend pas l'erreur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <?xml version="1.0" encoding="utf-8"?> <resources> <style name="MyCustomProgressStyle"> <item name="android:indeterminateOnly">false</item> <item name="android:progressDrawable">@drawable/custom_progress_bar_horizontal</item> <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item> </style> </resources>
Partager