1. Download our Official Android App: Forums for Android!

Support please why will this my login code not word

Discussion in 'Android Help' started by Briant Softy, May 10, 2016.

?

why is view in this code not working

  1. view

    0 vote(s)
    0.0%
  2. view

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. Briant Softy

    Briant Softy Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    1
    Joined:
    May 10, 2016

    May 10, 2016
    1
    0
    15
    Male
    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);
    }
    }
     

    Advertisement

Share This Page

Loading...