我正在编写Android应用。我的应用程序纯粹是在Android 7.0版本上运行。但我记得我必须改变我的minSdkNumer低手机从我的应用程序中受益。当我尝试在API 21上启动我的应用程序时,它给出了错误消息。我认为我的错误是在Edittext中,所以我改变了。但它仍然无效。我该如何解决?顺便说一下:back_input没有错误。我试图删除并启动。它不起作用。
这是giris_ekranı.layout:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".giris_ekrani"
android:background="#FAB300">
<LinearLayout
android:id="@+id/login_lyt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<ImageView
android:id="@+id/image_logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="20dp"
android:layout_gravity="center"
/>
<ImageView
android:id="@+id/image_figur"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:background="@drawable/user100" />
<EditText
android:id="@+id/kullanici"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="@drawable/back_input"
android:gravity="center|left"
android:hint="Kullanıcı Adınız"
android:lines="1"
android:inputType="textPersonName"
android:paddingLeft="15dp"
android:textColor="#17202A"
android:textColorHint="#FFFF"
android:textSize="18dp" />
<EditText
android:id="@+id/sifre"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="@drawable/back_input"
android:gravity="center|left"
android:hint="Şifre"
android:lines="1"
android:inputType="textPassword"
android:paddingLeft="15dp"
android:textColor="#17202A"
android:textColorHint="#FFFF"
android:textSize="18dp" />
<Button
android:id="@+id/button_giris"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="@drawable/buton"
android:gravity="center"
android:paddingLeft="15dp"
android:text="Giriş Yap"
android:textAllCaps="false"
android:textColor="@color/arama"
android:textSize="23dp" />
<Button
android:id="@+id/btn_ziyaret"
android:layout_width="match_parent"
android:layout_height="25dp"
android:text="@string/ziyaret_i_olarak_giri_yap"
android:gravity="center"
android:textSize="20sp"
android:textAllCaps="false"
android:background="@drawable/none"
android:layout_marginTop="10dp"
android:textColor="#FFFF"/>
<Button
android:id="@+id/btnuyelik"
android:layout_width="match_parent"
android:layout_height="25dp"
android:text="Kayıt Ol"
android:gravity="center"
android:textSize="20sp"
android:textAllCaps="false"
android:background="@drawable/none"
android:layout_marginTop="10dp"
android:textColor="#FFFF"/>
<Button
android:id="@+id/btnsifre_unuttum"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="25dp"
android:text="Şifremi Unuttum"
android:gravity="center"
android:textSize="15sp"
android:background="@drawable/none"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
android:textColor="#FFFF"/>
</LinearLayout>
</RelativeLayout>
我的第一个活动:`
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class giris_ekrani extends AppCompatActivity {
private static final String TAG = "giris_ekrani";
EditText kullanıcı_edittext ;
EditText sifre_edittext ;
Button giris_button ;
Button ziyaret_button ;
Button kayıt_ol_button ;
Button sifremi_unuttum_button ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_giris_ekrani);
kullanıcı_edittext = (EditText) findViewById(R.id.kullanici);
sifre_edittext = (EditText) findViewById(R.id.sifre);
giris_button = (Button) findViewById(R.id.button_giris);
ziyaret_button = (Button) findViewById(R.id.btn_ziyaret);
kayıt_ol_button = (Button) findViewById(R.id.btnuyelik);
sifremi_unuttum_button = (Button)findViewById(R.id.btnsifre_unuttum);
giris_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent bottom_bar_intent = new Intent(giris_ekrani.this ,bottom_bar.class);
startActivity(bottom_bar_intent);
// registir();
}
});
kayıt_ol_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent kayıt_ekranı_ıntent = new Intent(giris_ekrani.this,kayit_ekrani.class);
startActivity(kayıt_ekranı_ıntent);
}
});
sifremi_unuttum_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent sifremi_unuttum_ıntent = new Intent(giris_ekrani.this,sifremi_unuttum.class);
startActivity(sifremi_unuttum_ıntent);
}
});
}
}`
这是我的日志猫:
05-03 23:46:41.955 4134-4134/something.about.berkay.isim E/AndroidRuntime: FATAL EXCEPTION: main
Process: something.about.berkay.isim, PID: 4134
java.lang.RuntimeException: Unable to start activity ComponentInfo{something.about.berkay.isim/something.about.berkay.isim.giris_ekrani}: android.view.InflateException: Binary XML file line #37: Error inflating class EditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class EditText
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
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 something.about.berkay.isim.giris_ekrani.onCreate(giris_ekrani.java:22)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.content.res.Resources$NotFoundException: Resource "something.about.berkay.isim:drawable/back_input" (7f08005f) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f08005f a=-1 r=0x7f08005f}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2390)
at android.content.res.Resources.loadDrawable(Resources.java:2330)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.view.View.<init>(View.java:3730)
at android.widget.TextView.<init>(TextView.java:634)
at android.widget.EditText.<init>(EditText.java:65)
at android.widget.EditText.<init>(EditText.java:61)
at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:64)
at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:60)
at android.support.v7.app.AppCompatViewInflater.createEditText(AppCompatViewInflater.java:191)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:113)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1035)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
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 something.about.berkay.isim.giris_ekrani.onCreate(giris_ekrani.java:22)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
我的傻瓜:
android {
compileSdkVersion 27
defaultConfig {
applicationId
minSdkVersion 17
targetSdkVersion 27
versionCode 15
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:design:27.1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.okhttp3:okhttp:3.4.2'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.roughike:bottom-bar:2.3.1'
compile 'com.github.sd6352051.niftydialogeffects:niftydialogeffects:1.0.0@aar'
compile 'com.mindorks:paracamera:0.2.2'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
答案 0 :(得分:1)
我用传统方式找到了我的例外。
机器人:文字颜色=&#34;#FFFF&#34; ---&GT;必须是android:textColor =&#34; #FFFFFFF&#34;。