Reputation: 23
i Have Error when i choose ImageButton to get next Activty here the logcat :
E/AndroidRuntime(820): FATAL EXCEPTION: main
E/AndroidRuntime(820): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pengendalipagar/com.ta.pengendalipagar.MnUtama}: android.view.InflateException: Binary XML file line #52: Error inflating class <unknown>
E/AndroidRuntime(820): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
E/AndroidRuntime(820): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime(820): at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime(820): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime(820): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(820): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(820): at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime(820): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(820): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(820): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime(820): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime(820): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(820): Caused by: android.view.InflateException: Binary XML file line #52: Error inflating class <unknown>
E/AndroidRuntime(820): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
E/AndroidRuntime(820): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
E/AndroidRuntime(820): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
E/AndroidRuntime(820): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
This is My Code activity1 activity_login.xml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/cover" >
<TextView
android:id="@+id/txtPasscode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/editText1"
android:layout_alignLeft="@+id/editText1"
android:layout_marginBottom="42dp"
android:text="@string/passcode"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<ImageButton
android:id="@+id/imbLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtPasscode"
android:layout_marginLeft="26dp"
android:layout_marginTop="22dp"
android:src="@drawable/login"/>
<ImageButton
android:id="@+id/imbExit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imbLogin"
android:layout_marginLeft="18dp"
android:layout_toRightOf="@+id/imbLogin"
android:src="@drawable/exit"/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp"
android:src="@drawable/logo" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imbLogin"
android:layout_alignRight="@+id/imbExit"
android:layout_below="@+id/imageView1"
android:layout_marginTop="69dp"
android:ems="10"
android:inputType="numberPassword" >
<requestFocus />
</EditText>
</RelativeLayout>
and This my code of activity1 LoginActivity.java :
package com.ta.pengendalipagar;
import com.example.pengendalipagar.R;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
public class LoginActivity extends Activity{
/*private ImageButton Login;
private ImageButton Exit;
private EditText Passcode;*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ImageButton Login = (ImageButton)findViewById(R.id.imbLogin);
ImageButton Exit = (ImageButton)findViewById(R.id.imbExit);
//EditText Passcode = (EditText)findViewById(R.id.txtPasscode);
Login.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
callLogin();
}
});
Exit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
callKeluar();
}
});
}
public void callLogin(){
Intent myMenu = new Intent(this, MnUtama.class);
startActivity(myMenu);
}
public void callKeluar(){
finish();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.login, menu);
return true;
}
}
This is My Code activity2 activity_mnutama.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/cover">
<ImageButton
android:id="@+id/imbOpen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="26dp"
android:layout_marginTop="141dp"
android:src="@drawable/open" />
<ImageButton
android:id="@+id/imbClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imbOpen"
android:layout_marginLeft="18dp"
android:layout_toRightOf="@+id/imbOpen"
android:src="@drawable/close" />
<ImageButton
android:id="@+id/imbSetting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imbOpen"
android:layout_below="@+id/imbOpen"
android:layout_marginTop="25dp"
android:src="@drawable/setting" />
<ImageButton
android:id="@+id/imbExit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/imbClose"
android:layout_alignTop="@+id/imbSetting"
android:src="@drawable/exit"/>
<EditText
android:id="@+id/txtStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/imbClose"
android:layout_alignLeft="@+id/imbOpen"
android:layout_alignRight="@+id/imbClose"
android:layout_marginBottom="16dp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp"
android:text="@string/main_menu"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@style/AppBaseTheme"
android:textSize="15pt"
android:textStyle="bold" />
</RelativeLayout>
and This my code of activity2 MnUtama.java :
package com.ta.pengendalipagar;
import com.example.pengendalipagar.R;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
public class MnUtama extends Activity {
/*private ImageButton Open;
private ImageButton Close;
private ImageButton Setting;
private ImageButton Exit;
private EditText Status;*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mnutama);
ImageButton Open = (ImageButton)findViewById(R.id.imbOpen);
ImageButton Close = (ImageButton)findViewById(R.id.imbClose);
ImageButton Setting = (ImageButton)findViewById(R.id.imbSetting);
ImageButton Exit = (ImageButton)findViewById(R.id.imbExit);
EditText Status = (EditText)findViewById(R.id.txtStatus);
Exit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
callKeluar();
}
});
}
public void callKeluar(){
finish();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.login, menu);
return true;
}
}
And this is my Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pengendalipagar"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.ta.pengendalipagar.LoginActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.ta.pengendalipagar.MnUtama"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Upvotes: 1
Views: 6971
Reputation: 11234
I believe the problem is at the following string at the last TextView
of activity_mnutama.xml
:
android:textColor="@style/AppBaseTheme"
You are doing it a wrong way, delete this line. To set textColor
via style, you should add this line to the TextView
declaration:
style="@style/AppBaseTheme"
where AppBaseTheme
is like following:
<style name="AppBaseTheme">
<item name="android:textColor">#FFF</item>
</style>
Upvotes: 1