CircularProgressButton
дает мне ошибку, и я не знаю, как ее исправить.
Это код:
xml
код:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="esame.progetto.xhondar.github.com.info.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways"
app:layout_collapseMode="parallax"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="20sp"
android:fontFamily="serif"
android:textStyle="bold"
android:layout_marginLeft="4dp"
android:textAlignment="center"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="25dp"
>
<TextView
android:id="@+id/text"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Seleziona città:"
android:textSize="16dp"
/>
<Spinner
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:id="@+id/spin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:spinnerMode="dialog"
>
</Spinner>
</LinearLayout>
<!-- This line is 63--><com.dd.CircularProgressButton
android:layout_marginTop="50dp"
android:layout_marginLeft="48dp"
android:layout_marginRight="48dp"
android:textSize="16sp"
android:textColor="@color/white"
android:backgroundTint="?attr/colorPrimary"
android:layout_gravity="center"
android:id="@+id/cpbLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cpb_cornerRadius="48dp"
app:cpb_textIdle="INVIO"/>
<ImageView
android:id="@+id/image"
android:layout_marginTop="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_height="250dp"
android:layout_marginBottom="50dp"
android:layout_width="match_parent"
android:layout_gravity="center"
android:scaleType="centerCrop"/>
</LinearLayout>
</ScrollView>
Java
код:
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
private Button button;
public String s;
CircularProgressButton circularProgressButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Spinner spinner = (Spinner) findViewById(R.id.spin);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.cities, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
setS(spinner.getSelectedItem().toString());
circularProgressButton = (CircularProgressButton) findViewById(R.id.cpbLogin);
circularProgressButton.setIndeterminateProgressMode(true);
circularProgressButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(circularProgressButton.getProgress()==0)
{
circularProgressButton.setProgress(30);
}
else if (circularProgressButton.getProgress()==-1)
{
circularProgressButton.setProgress(0);
}
else if (circularProgressButton.getProgress()==100)
{
Intent intent = new Intent(MainActivity.this, tab.class);
intent.putExtra("message", getS());
startActivity(intent);
}
}
});
}
public void setS(String ss){
s=ss;
}
public String getS(){
return s;
}
int i = 0;
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String sSelected = parent.getItemAtPosition(position).toString();
if(i==0){
}else {
Toast.makeText(this, sSelected, Toast.LENGTH_SHORT).show();
}
i++;
setS(parent.getItemAtPosition(position).toString());
ImageView img = (ImageView)findViewById(R.id.image);
Drawable d;
switch (s){
case "Carpi": d = getResources().getDrawable(R.drawable.carpi); img.setImageDrawable(d); break;
case "Berlino": d = getResources().getDrawable(R.drawable.berlino); img.setImageDrawable(d); break;
case "Trieste": d = getResources().getDrawable(R.drawable.trieste); img.setImageDrawable(d); break;
case "Lubiana": d = getResources().getDrawable(R.drawable.lubiana); img.setImageDrawable(d); break;
case "Norimberga": d = getResources().getDrawable(R.drawable.norimberga); img.setImageDrawable(d); break;
default: break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}
Это ошибка, которую android-studio
дает мне:
Process: esame.progetto.xhondar.github.com.info, PID: 25577
java.lang.RuntimeException: Unable to start activity ComponentInfo{esame.progetto.xhondar.github.com.info/esame.progetto.xhondar.github.com.info.MainActivity}: android.view.InflateException: Binary XML file line #63: Error inflating class com.dd.CircularProgressButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2568)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2648)
at android.app.ActivityThread.access$800(ActivityThread.java:182)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1493)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5690)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)
Caused by: android.view.InflateException: Binary XML file line #63: Error inflating class com.dd.CircularProgressButton
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at esame.progetto.xhondar.github.com.info.MainActivity.onCreate(MainActivity.java:46)
at android.app.Activity.performCreate(Activity.java:6161)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2515)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2648)
at android.app.ActivityThread.access$800(ActivityThread.java:182)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1493)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5690)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at esame.progetto.xhondar.github.com.info.MainActivity.onCreate(MainActivity.java:46)
at android.app.Activity.performCreate(Activity.java:6161)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2515)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2648)
at android.app.ActivityThread.access$800(ActivityThread.java:182)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1493)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5690)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x3
at android.content.res.TypedArray.getDimension(TypedArray.java:566)
at com.dd.CircularProgressButton.initAttributes(CircularProgressButton.java:196)
at com.dd.CircularProgressButton.init(CircularProgressButton.java:84)
at com.dd.CircularProgressButton.<init>(CircularProgressButton.java:73)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at esame.progetto.xhondar.github.com.info.MainActivity.onCreate(MainActivity.java:46)
at android.app.Activity.performCreate(Activity.java:6161)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2515)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2648)
at android.app.ActivityThread.access$800(ActivityThread.java:182)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1493)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5690)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963)
at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)
Это gradle
:
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.android.volley:volley:1.0.0'
testImplementation 'junit:junit:4.12'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'
implementation 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
Я пробовал некоторые решения, но ни одно из них не решило мою проблему