خرید بک لینک

Vote count: 0

Im new to Android Studios and I have created and app that allows the user to register a useame and password, save it to a database and then login to a system. I thought the code was correct and there is no errors, but i don't think my buttons are working to actually carry out the tasks. Below is my code:

Main Activity

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

TextView tvRegisterLink;


DatabaseHelper helper = new DatabaseHelper(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tvRegisterLink = (TextView) findViewById(R.id.tvRegisterLink);

    tvRegisterLink.setOnClickListener(this);
}

public void onButtonClick(View v)
{
    if(v.getId() == R.id.bLogin)
    {
        EditText a = (EditText) findViewById(R.id.etUseame);
        String str = a.getText().toString();
        EditText b = (EditText) findViewById(R.id.etPassword);
        String pass = b.getText().toString();

        String password = helper.searchPass(str);
        if(pass.equals(password))
        {
            Intent i = new Intent(MainActivity.this, Options.class);
            i.putExtra("Useame",str);
            startActivity(i);
        }
        else
        {
            Toast temp = Toast.makeText(MainActivity.this , "Useame and Password Dont Match!" , Toast.LENGTH_SHORT);
            temp.show();
        }
    }
}

@Override
public void onClick(View v) {
    switch(v.getId()){
        case R.id.tvRegisterLink:
            startActivity(new Intent(this, register.class));

            break;
    }
}

}

Register Class:

public class register extends AppCompatActivity {

DatabaseHelper helper = new DatabaseHelper(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);
}

public void onbRegisterClick(View v)
{
    if(v.getId() == R.id.bRegister)
    {
        EditText useame = (EditText) findViewById(R.id.RegUseame);
        EditText password = (EditText) findViewById(R.id.RegPassword);
        EditText password2 = (EditText) findViewById(R.id.RegPassword2);

        String useamestr = useame.getText().toString();
        String passwordstr = password.getText().toString();
        String password2str = password2.getText().toString();

        if(!passwordstr.equals(password2str))
        {
            //pop-up message
            Toast pass = Toast.makeText(register.this , "Passwords Do Not Match!" , Toast.LENGTH_SHORT);
            pass.show();
        }
        else
        {
            //insert the details in the database
            Contact c = new Contact();
            c.setUseame(useamestr);
            c.setPassword(passwordstr);

            helper.insertContact(c);
        }
    }
}
}

Im fairly certain it has something to do with the onButtonClick method in the main activity and the onbRegisterClick method in the register because they are both saying that the methods are not being used. Any help at all is greatly appreciated!

asked 57 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 9 فروردين 1395 ساعت: 3:18

صفحه بندی