Reputation:
I am stuck trying to figure out how to check the parser database to see if it corresponds to a user input.
For example if the username from the input exists then I toast "Logged in" My issue lies with figuring out how to wrap my head around that concept.
A bit of a newbie to android programming so bare patience, and I believe the error is at ERROR HERE in my code.
The error from logical is error: cannot find symbol variable menu_login
, any help would be appreciated.
package com.example.dan.loginsample;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.dan.loginsample.R.id;
import com.example.dan.loginsample.R.layout;
import com.example.dan.loginsample.R.menu;
import com.parse.CountCallback;
import com.parse.FindCallback;
import com.parse.LogInCallback;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;
import java.text.ParseException;
import java.util.List;
public class Login extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(layout.activity_login);
EditText username = (EditText) this.findViewById(id.userloginname);
EditText password = (EditText) this.findViewById(id.userpassword);
TextView neighbourView = new TextView(this);
Button button_test;
button_test = (Button) this.findViewById(id.btnLogin);
button_test.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
String usersname = username.getText().toString();
String passwoord = password.getText().toString();
//ParseQuery<ParseObject> query = ParseQuery.getQuery("Parking");
ParseUser.logInInBackground(usersname, passwoord, new LogInCallback() {
@Override
public void done(ParseUser user, com.parse.ParseException e) {
if (user != null) {
// Hooray! The user is logged in.
} else {
//
}
}
});
// return false;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//******Error HERE getMenuInflater().inflate(menu.menu_login, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
And my XML
<!-- Username Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="@string/username"/>
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:layout_marginBottom="20dip"
android:singleLine="true"
android:id="@+id/userloginname"
android:inputType="text" />
<!-- Password Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="@string/password"/>
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:singleLine="true"
android:password="true"
android:inputType="textPassword"
android:id="@+id/userpassword" />
<!-- Login button -->
<Button android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="@string/loginButton"/>
Upvotes: 0
Views: 88
Reputation: 2806
Change your code from this
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//******Error HERE getMenuInflater().inflate(menu.menu_login, menu);
return true;
}
into this
@Override
public boolean onCreateOptionsMenu(Menu menu1) {
getMenuInflater().inflate(menu.menu_login, menu1);
return true;
}
the variable name in the argument is also menu . That was your problem
Upvotes: 1