I am trying to copy design from a template, but I am having casting errors. I am new to using 3rd party libraries and to Android programming as well, so I hope this wont be a problem.
Also, I have 2 text-fields and 2 buttons(Register, Login). Can anyone tell me by seeing the login-code that I am setting it's type
correctly. Thanks a lot.
Error log :
1-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: FATAL EXCEPTION: main
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: Process: mypackage.restaurantlunchify, PID: 7038
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: java.lang.ClassCastException: mypackage.restaurantlunchify.Templates.FloatLabeledEditText cannot be cast to android.widget.EditText
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at mypackage.restaurantlunchify.Login.Login$2.onClick(Login.java:61)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.view.View.performClick(View.java:4785)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at mypackage.restaurantlunchify.Templates.MaterialRippleLayout$PerformClickEvent.run(MaterialRippleLayout.java:568)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at mypackage.restaurantlunchify.Templates.MaterialRippleLayout$3.onAnimationEnd(MaterialRippleLayout.java:315)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd(AnimatorSet.java:829)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1089)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:666)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:682)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:792)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:596)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:556)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:778)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.os.Looper.loop(Looper.java:155)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5696)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
11-17 16:26:18.136 7038-7038/mypackage.restaurantlunchify E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Login code :
public class Login extends Activity {
public static RestTemplate rest = StaticRestTemplate.rest;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
TextView restaurantRegister = (TextView) findViewById(R.id.registerRestaurantButton);
restaurantRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!(v == null)) {
Intent intent = new Intent(Login.this, AddRestaurant.class);
startActivity(intent);
finish();
}
}
});
TextView loginButton = (TextView) findViewById(R.id.LoginButton);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!(v == null)) {
EditText userEmail = (EditText) findViewById(R.id.usernameText);
EditText userPassword = (EditText) findViewById(R.id.PasswordField);
}
}
Login.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:background="@drawable/login_background_dark"
android:orientation="vertical"
android:padding="24dp"
android:weightSum="1">
<mypackage.restaurantlunchify.Templates.FontelloTextView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="64dp"
android:layout_marginLeft="140dp"
android:layout_marginStart="140dp"
android:layout_marginTop="64dp"
android:text="@string/fontello_logo"
android:textColor="@color/main_color_50"
android:textSize="64dp"
tools:ignore="SpUsage" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
>
<mypackage.restaurantlunchify.Templates.FontelloTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/fontello_user"
android:textColor="@color/main_color_50"
android:textSize="16dp"
tools:ignore="SpUsage" />
<mypackage.restaurantlunchify.Templates.FloatLabeledEditText
android:id="@+id/usernameText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_weight="1"
app:fletHintTextColor="@color/main_color_A100"
app:fletSingleLine="true"
app:fletFloatingHint="Username"
app:fletTextColor="@color/main_color_grey_50"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:gravity="center_vertical"
>
<mypackage.restaurantlunchify.Templates.FontelloTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/fontello_password"
android:textColor="@color/main_color_50"
android:textSize="16dp"
tools:ignore="SpUsage" />
<mypackage.restaurantlunchify.Templates.FloatLabeledEditText
android:id="@+id/PasswordField"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_weight="1"
app:fletFloatingHint="@string/password"
app:fletHintTextColor="@color/main_color_A100"
app:fletPassword="true"
app:fletSingleLine="true"
app:fletTextColor="@color/main_color_grey_50" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="54dp">
<mypackage.restaurantlunchify.Templates.MaterialRippleLayout
style="@style/RippleStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
android:layout_marginRight="3dp"
android:text="@string/fontello_password"
app:rippleColor="@color/main_color_grey_400">
<mypackage.restaurantlunchify.Templates.RobotoTextView
android:id="@+id/LoginButton"
style="@style/ButtonStyle.RaisedEmpty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.08"
android:background="@color/main_color_900"
app:fletFloatingHint="@string/password"
android:minWidth="112dp"
android:text="Login"
android:textColor="#fff" />
</mypackage.restaurantlunchify.Templates.MaterialRippleLayout>
<mypackage.restaurantlunchify.Templates.MaterialRippleLayout
style="@style/RippleStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="54dp"
app:rippleColor="@color/main_color_grey_400">
<mypackage.restaurantlunchify.Templates.RobotoTextView
android:id="@+id/registerRestaurantButton"
style="@style/ButtonStyle.RaisedEmpty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/main_color_900"
android:minWidth="112dp"
android:text="Register"
android:textColor="#fff" />
</mypackage.restaurantlunchify.Templates.MaterialRippleLayout>
</LinearLayout>
</LinearLayout>
If anymore files or information is required, kindly let me know. The reference template is not even processing the input in Java-code, so I don't know what to name it.
Here is what each of those UI file extends :
public class FontelloTextView extends TextView public class FloatLabeledEditText extends LinearLayout public class MaterialRippleLayout extends FrameLayout { public class RobotoTextView extends TextView {
Thanks.. :-)
There're many FloatLabeledEditText
.So I don't know which kind of FloatLabeledEditText
you are using.
to
<mypackage.restaurantlunchify.Templates.FloatLabeledEditText
android:id="@+id/usernameTextFloat"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_weight="1"
app:fletHintTextColor="@color/main_color_A100"
app:fletSingleLine="true"
app:fletFloatingHint="Username"
app:fletTextColor="@color/main_color_grey_50">
<EditText @+id/usernameText android:layout_height="wrap_content" android:layout_width="match_parent" />
<mypackage.restaurantlunchify.Templates.FloatLabeledEditText/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.