请帮帮我。我已经尝试了一切,但无法解决这个问题。模拟器正在提示“应用程序名称不断停止”。我的API等级是28。谢谢您。
package com.example.testrun;
import android.content.Intent;
import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
Button btnSignIn,btnSignUp;
TextView txtslogan;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSignIn = findViewById(R.id.btnSignIn);
btnSignUp = findViewById(R.id.btnSignUp);
txtslogan = findViewById(R.id.txtslogan);
Typeface face = Typeface.createFromAsset(getAssets(),"fonts/Pacifico.ttf");
txtslogan.setTypeface(face);
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent signIn = new Intent(MainActivity.this,SignIn.class);
startActivity(signIn);
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/layam"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blurry"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:contentDescription="@string/decs"
android:src="@drawable/zomato_660_020218051156" />
<TextView
android:id="@+id/txtslogan"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/txtslogan"
android:textColor="@android:color/holo_red_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:weightSum="2">
<info.hoang8f.widget.FButton
android:id="@+id/btnSignUp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:text="@string/btnSignUp"
android:textColor="@android:color/white"
app:buttonColor="@color/btnSignUp"
app:cornerRadius="5dp"
app:shadowColor="@android:color/black"
app:shadowEnabled="true"
app:shadowHeight="4dp" />
<info.hoang8f.widget.FButton
android:id="@+id/btnSignIn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:text="@string/btnSignIn"
android:textColor="@android:color/white"
app:buttonColor="@color/btnSignActive"
app:cornerRadius="5dp"
app:shadowColor="@android:color/black"
app:shadowEnabled="true"
app:shadowHeight="4dp" />
</LinearLayout>
</RelativeLayout>
2019-03-04 09:29:42.314 7873-7884/? E/example.testru: Failed to send jdwp-handshake response.: Broken pipe
2019-03-04 09:29:43.660 7873-7873/com.example.testrun E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.testrun, PID: 7873
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testrun/com.example.testrun.MainActivity}: android.view.InflateException: Binary XML file line #40: Binary XML file line #40: Error inflating class info.hoang8f.widget.FButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #40: Binary XML file line #40: Error inflating class info.hoang8f.widget.FButton
Caused by: android.view.InflateException: Binary XML file line #40: Error inflating class info.hoang8f.widget.FButton
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.testrun.MainActivity.onCreate(MainActivity.java:20)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5
at android.content.res.TypedArray.getColor(TypedArray.java:482)
at info.hoang8f.widget.FButton.parseAttrs(FButton.java:116)
at info.hoang8f.widget.FButton.<init>(FButton.java:52)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.testrun.MainActivity.onCreate(MainActivity.java:20)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
“在com.example.testrun.MainActivity.onCreate(MainActivity.java:20)处”-logcat中的这一行是蓝色的。
答案 0 :(得分:0)
在布局xml中似乎为FBbutton取消了颜色。
Can't convert value at index 1 to color: type=0x5 at
android.content.res.TypedArray.getColor(TypedArray.java:482)
您应该检查那些。也许先删除所有颜色属性,然后再添加一个以找出罪魁祸首。
答案 1 :(得分:0)
显然,这是您正在使用的库中的错误:
https://github.com/hoang8f/android-flat-button/issues/41
根据问题的评论,此问题仍未解决。 但是似乎有人分叉了库并对其进行了修复。 因此,您应该尝试使用此代替: