package com.example.bestbroadcastpractice;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
/**
-
Created by xingpengfei on 2016/5/30.
*/
public class LoginActivity extends BaseActivity {
private EditText accountEdit;
private EditText passwordEdit;
private Button login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
accountEdit = (EditText) findViewById(R.id.account);
passwordEdit = (EditText) findViewById(R.id.password);
login = (Button) findViewById(R.id.login);
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)String account = accountEdit.getText().toString(); String password = passwordEdit.getText().toString();
//如果账号是admin且密码是123456,就认为登录成功
if (account.equals("admin") && password.equals("123456"))
{
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
else {
Toast.makeText(LoginActivity.this, "account or password is invalid",
Toast.LENGTH_SHORT).show();
}
}
});
}
}
显示的login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) 这里有错!