• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help please why will this my login code not word

why is view in this code not working

  • view

    Votes: 0 0.0%
  • view

    Votes: 0 0.0%

  • Total voters
    0
package com.example.fonjo_fils.nwi;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Button;
import android.widget.Toast;
import android.content.Intent;

public class LoginActivity extends AppCompatActivity {
private static EditText username;
private static EditText password;
private static TextView attempts;
private static Button login_btn;
int attempt_counter = 5;

@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
LoginButton();
}
});
}
public void LoginButton(){
username = (EditText)findViewById(R.id.editText_user);
password = (EditText)findViewById(R.id.editText_password);
attempts = (EditText)findViewById(R.id.textView_attempts_count);
login_btn = (Button)findViewById(R.id.button_login);
attempts.setText(Integer.toString(attempt_counter));
login_btn.setOnClickListener(
new veiw.onClickListener(){
@override
public void onClick(view v) {
if(username.getText().toString().equals("Briant") &&
password.getText().toString().equals("good") ){
Toast.makeText(LoginActivity.this,"user and password is correct",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent("com.example.fonjo_fils.nwi.User");
startActivity(intent);
}else{
Toast.makeText(LoginActivity.this,"user and password is not correct",
Toast.LENGTH_SHORT).show();
attempt_counter--;
attempts.setText(Integer.toString(attempt_counter));
if(attempt_counter== 0){
login_btn.setEnabled(false);
}
}

}
}
);
}
@override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.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
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones