Java 字符串无法解析或不是字段?
基本上我有一个用于解析的登录和注册代码。我正在努力解决这个问题。我有: LoginSignupActivity.javaJava 字符串无法解析或不是字段?,java,android,xml,parse-platform,Java,Android,Xml,Parse Platform,基本上我有一个用于解析的登录和注册代码。我正在努力解决这个问题。我有: LoginSignupActivity.java package com.androidbegin.parselogintutorial; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnCli
package com.androidbegin.parselogintutorial;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.parse.LogInCallback;
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
public class LoginSignupActivity extends Activity {
// Declare Variables
Button loginbutton;
Button signup;
String usernametxt;
String passwordtxt;
EditText password;
EditText username;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the view from main.xml
setContentView(R.layout.main);
// Locate EditTexts in main.xml
username = (EditText) findViewById(R.id.username);
password = (EditText) findViewById(R.id.password);
// Locate Buttons in main.xml
loginbutton = (Button) findViewById(R.id.login);
signup = (Button) findViewById(R.id.signup);
// Login Button Click Listener
loginbutton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// Retrieve the text entered from the EditText
usernametxt = username.getText().toString();
passwordtxt = password.getText().toString();
// Send data to Parse.com for verification
ParseUser.logInInBackground(usernametxt, passwordtxt,
new LogInCallback() {
public void done(ParseUser user, ParseException e) {
if (user != null) {
// If user exist and authenticated, send user to Welcome.class
Intent intent = new Intent(
LoginSignupActivity.this,
Welcome.class);
startActivity(intent);
Toast.makeText(getApplicationContext(),
"Successfully Logged in",
Toast.LENGTH_LONG).show();
finish();
} else {
Toast.makeText(
getApplicationContext(),
"No such user exist, please signup",
Toast.LENGTH_LONG).show();
}
}
});
}
});
// Sign up Button Click Listener
signup.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// Retrieve the text entered from the EditText
usernametxt = username.getText().toString();
passwordtxt = password.getText().toString();
// Force user to fill up the form
if (usernametxt.equals("") && passwordtxt.equals("")) {
Toast.makeText(getApplicationContext(),
"Please complete the sign up form",
Toast.LENGTH_LONG).show();
} else {
// Save new user data into Parse.com Data Storage
ParseUser user = new ParseUser();
user.setUsername(usernametxt);
user.setPassword(passwordtxt);
user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
// Show a simple Toast message upon successful registration
Toast.makeText(getApplicationContext(),
"Successfully Signed up, please log in.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),
"Sign up Error", Toast.LENGTH_LONG)
.show();
}
}
});
}
}
});
}
}
和我的loginsignup.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dip" >
<TextView
android:id="@+id/txtusername"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Username" />
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/txtusername"
android:inputType="text" />
<TextView
android:id="@+id/txtpassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/username"
android:text="@string/Password" />
<EditText
android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/txtpassword"
android:inputType="textPassword" />
<Button
android:id="@+id/login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/password"
android:text="@string/LoginBtn" />
<Button
android:id="@+id/signup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login"
android:text="@string/SignupBtn" />
</RelativeLayout>
当我尝试运行它时,我得到“字符串无法解析或不是字段。”(字符串用作占位符)。我是Android开发的新手。任何帮助都会很好。而不是-
setContentView(R.layout.main);
写这个-
setContentView(R.layout.loginsignup);
而不是-
setContentView(R.layout.main);
写这个-
setContentView(R.layout.loginsignup);
而不是-
setContentView(R.layout.main);
写这个-
setContentView(R.layout.loginsignup);
而不是-
setContentView(R.layout.main);
写这个-
setContentView(R.layout.loginsignup);
尝试清除您的项目 从第三方库项目中删除私有库(如果有的话) 添加到Android v4库的构建路径
然后再次清除项目。尝试清除项目 从第三方库项目中删除私有库(如果有的话) 添加到Android v4库的构建路径
然后再次清除项目。尝试清除项目 从第三方库项目中删除私有库(如果有的话) 添加到Android v4库的构建路径
然后再次清除项目。尝试清除项目 从第三方库项目中删除私有库(如果有的话) 添加到Android v4库的构建路径
然后再次清理你的项目。你的
LoginSignupActivity.java
代码没有任何意义,我不想发布全部内容。但我想我会的@PavelDudkaWhere您在哪里得到这个错误?在我的登录gnupactivity中。在这些地方username=(EditText)findViewById(R.id.username);密码=(EditText)findViewById(R.id.password);//在main.xml loginbutton=(Button)findviewbyd(R.id.login)中找到按钮;注册=(按钮)findViewById(R.id.signup)
@SotiriosDelimanolisyourLoginSignupActivity.java
code没有任何意义,我不想发布整件事。但我想我会的@PavelDudkaWhere您在哪里得到这个错误?在我的登录gnupactivity中。在这些地方username=(EditText)findViewById(R.id.username);密码=(EditText)findViewById(R.id.password);//在main.xml loginbutton=(Button)findviewbyd(R.id.login)中找到按钮;注册=(按钮)findViewById(R.id.signup)
@SotiriosDelimanolisyourLoginSignupActivity.java
code没有任何意义,我不想发布整件事。但我想我会的@PavelDudkaWhere您在哪里得到这个错误?在我的登录gnupactivity中。在这些地方username=(EditText)findViewById(R.id.username);密码=(EditText)findViewById(R.id.password);//在main.xml loginbutton=(Button)findviewbyd(R.id.login)中找到按钮;注册=(按钮)findViewById(R.id.signup)
@SotiriosDelimanolisyourLoginSignupActivity.java
code没有任何意义,我不想发布整件事。但我想我会的@PavelDudkaWhere您在哪里得到这个错误?在我的登录gnupactivity中。在这些地方username=(EditText)findViewById(R.id.username);密码=(EditText)findViewById(R.id.password);//在main.xml loginbutton=(Button)findviewbyd(R.id.login)中找到按钮;注册=(按钮)findViewById(R.id.signup)
@SotiriosDelimanolisI仍然收到相同的错误。导入项目的R文件,删除“android.R”。我似乎找不到“android.R”,所以导入此导入android.R代码>?不,不是那个R,你必须导入你包的R。我仍然收到相同的错误。导入你项目的R文件,删除“android.R”。我似乎找不到“android.R”,所以导入这个导入android.R代码>?不,不是那个R,你必须导入你包的R。我仍然收到相同的错误。导入你项目的R文件,删除“android.R”。我似乎找不到“android.R”,所以导入这个导入android.R代码>?不,不是那个R,你必须导入你包的R。我仍然收到相同的错误。导入你项目的R文件,删除“android.R”。我似乎找不到“android.R”,所以导入这个导入android.R代码>?不,不是R,您必须导入程序包的R。它修复了我当前的问题。但是现在R
出现了问题。现在转到您的项目属性/Java构建路径/order&export,然后按select all,然后按OK。继续尝试清除您的项目。同时确保您的xml文件不包含任何错误并正确保存。当您说clear时,您指的是clean it?它修复了我当前的问题。但是现在R
出现了问题。现在转到您的项目属性/Java构建路径/order&export,然后按select all,然后按OK。继续尝试清除您的项目。同时确保您的xml文件不包含任何错误并正确保存。当您说clear时,您指的是clean it?它修复了我当前的问题。但是现在R
出现了问题。现在转到您的项目属性/Java构建路径/order&export,然后按select all,然后按OK。继续尝试清除您的项目。同时确保您的xml文件不包含任何错误并正确保存。当您说clear时,您指的是clean it?它修复了我当前的问题。但是现在R
出现了问题。现在转到您的项目属性/Java构建路径/order&export,然后按select all,然后按OK。继续尝试清除您的项目。同时确保您的xml文件不包含任何错误并正确保存。当您说clear时,您的意思是清除它?