Its a simple login screen with two edit text one checkbox and a imagebutton ... it was working fine recently i have changed Button to imageButton and now it giving me problem
logcat
04-30 02:11:24.699: E/AndroidRuntime(9571): FATAL EXCEPTION: main
04-30 02:11:24.699: E/AndroidRuntime(9571): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.markitberry/com.example.markitberry.Login}: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.EditText
04-30 02:11:24.699: E/AndroidRuntime(9571): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
04-30 02:11:24.699: E/AndroidRuntime(9571): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
04-30 02:11:24.699: E/AndroidRuntime(9571): at android.app.ActivityThread.access$600(ActivityThread.java:127)
04-30 02:11:24.699: E/AndroidRuntime(9571): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
here is java
public class Login extends Activity implements AnimationListener {
ImageButton btnLogin;
EditText inputEmail,inputPassword;
CheckBox loginRemember;
// Animation
Animation animBounce1,animBounce2,animBounce3,animBounce4;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
// load the animation
animBounce1 = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.move_out);
animBounce2 = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.move_out_right);
animBounce3 = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.move_out);
animBounce4 = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fade_in);
// set animation listener
animBounce1.setAnimationListener(this);
animBounce2.setAnimationListener(this);
animBounce3.setAnimationListener(this);
animBounce4.setAnimationListener(this);
inputEmail=(EditText)findViewById(R.id.etloginEmail);
inputPassword=(EditText)findViewById(R.id.etloginPassword);
loginRemember=(CheckBox)findViewById(R.id.cbRemember);
ImageButton btnLogin =(ImageButton) findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
inputEmail.startAnimation(animBounce1);
inputPassword.startAnimation(animBounce2);
loginRemember.startAnimation(animBounce3);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.login_actions, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Take appropriate action for each action item click
switch (item.getItemId()) {
case R.id.action_call:
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:9871952704"));
startActivity(callIntent);
// help action
return true;
case R.id.action_email:
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto","markitberry@gmail.com", null));
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "message");
startActivity(Intent.createChooser(intent, "Choose an Email client :"));
case R.id.action_locate:
Intent i = new Intent(Login.this, Locate.class);
startActivity(i);
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
if (animation == animBounce3) {
Intent it=new Intent(Login.this,Home.class);
startActivity(it);
}
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation arg0) {
// TODO Auto-generated method stub
}
}
login.xml
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/login_bck"
android:gravity="center">
layout="@layout/login_cover"
android:layout_width="match_parent"
android:layout_height="match_parent" />
login_cover.xml
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/login_gradient_bck"
android:orientation="vertical" >
android:id="@+id/etloginPassword"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_above="@+id/cbRemember"
android:layout_alignLeft="@+id/etloginEmail"
android:layout_alignRight="@+id/etloginEmail"
android:layout_marginBottom="26dp"
android:background="#BFFFFFFF"
android:ems="10"
android:gravity="center"
android:hint="Enter Password"
android:inputType="textPassword"
android:textColor="#FFFFFF" />
android:id="@+id/etloginEmail"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_above="@+id/etloginPassword"
android:layout_centerHorizontal="true"
android:layout_margin="30dp"
android:layout_marginBottom="36dp"
android:background="#BFFFFFFF"
android:ems="10"
android:gravity="center"
android:hint="Enter Email"
android:inputType="textEmailAddress"
android:textColor="#FFFFFF" />
android:id="@+id/cbRemember"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_above="@+id/btnLogin"
android:layout_alignLeft="@+id/etloginPassword"
android:layout_alignRight="@+id/etloginPassword"
android:layout_marginBottom="62dp"
android:text="Remember Me"
android:textColor="#E6E6E6" />
android:id="@+id/btnLogin"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:background="@drawable/button"
android:src="@drawable/login_icon_2" />