小编ngx*_*311的帖子

如何向Firebase身份验证添加其他字段?年龄与性别

到目前为止,我真的很感动Firebase。但是我想知道如何定制用户电子邮件身份验证。我想添加以下字段:年龄性别,供用户在注册时填写。

这是我的SignUpActivity.java。

public class SignUpActivity extends AppCompatActivity {
private EditText inputEmail, inputPassword, signupInputUsername, signupInputAge;
private Button btnLinkLogin, btnSignUp, btnResetPassword;
private ProgressBar progressBar;
private FirebaseAuth auth;
private Spinner sexSpinner;
String defaultTextForSpinner = "Sex";
String[] arrayForSpinner = {"Male", "Female"};


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_signup);

    //Get Firebase auth instance
    auth = FirebaseAuth.getInstance();

    inputEmail = (EditText) findViewById(R.id.signup_input_email);
    signupInputUsername = (EditText) findViewById(R.id.signup_input_username);
    inputPassword = (EditText) findViewById(R.id.signup_input_password);
    signupInputAge = (EditText) findViewById(R.id.signup_input_birthday);
    sexSpinner = (Spinner)findViewById(R.id.spinner);
    sexSpinner.setAdapter(new CustomSpinnerAdapter(this, R.layout.spinner_row, …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-authentication

5
推荐指数
2
解决办法
8091
查看次数

单击 EditText 打开微调器

很抱歉打扰你们,但我一直在努力让这个工作正常进行。

我想要它做什么:

EditText 显示提示。

用户单击 EditText,打开微调器并选择他们的性别。然后将其转换为字符串并放入 EditText(gender) 中


它实际上在做什么: 在用户单击它之前,“男性”微调器中的第一个元素已经放入我的 EditText 中。(我从未看到我的提示:“性别”)......并且微调器不会当我尝试单击 EditText(性别)时完全打开

这是怎么回事?

我的代码:

    private Spinner sexSpinner;
    String[] arrayForSpinner = {"Male", "Female"};


    //Inside OnCreate method:
    sexSpinner = (Spinner)findViewById(R.id.spinner);
    adapter = new ArrayAdapter<String>(this, R.layout.spinner_row, arrayForSpinner);
    sexSpinner.setAdapter(adapter);


sexSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view,int position, long id) {
            gender.setText(sexSpinner.getSelectedItem().toString());

        }

gender.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View arg0, boolean hasFocus) {
            // TODO Auto-generated method stub
            if(hasFocus){
                sexSpinner.performClick();
            }
        }
    });
Run Code Online (Sandbox Code Playgroud)

布局:

<EditText
        android:layout_width="75dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="12dp"
        android:focusable="false"
        android:longClickable="false" …
Run Code Online (Sandbox Code Playgroud)

android spinner android-spinner

4
推荐指数
1
解决办法
1万
查看次数

Django-get_by_natural_key()恰好接受3个参数(给定2个)

我正在尝试创建用户登录。但是当我登录时,出现错误消息:

TypeError: get_by_natural_key() takes exactly 3 arguments (2 given)
Run Code Online (Sandbox Code Playgroud)

以前也有类似的问题,但从未解决过

我不知道这第三种要求是什么。我只是从Django自己的用户管理器中复制粘贴了get_by_natural_key,然后将其放入我自己的自定义模型中。

这是我的用户模型:

class CustomUserManager(models.Manager):
    def get_absolute_url(self):
        return "/u/%s/" % urlquote(self.username)

    def get_username(self):
        'Returns the username'
        return self.username

    def get_full_name(self):
        """
        #Returns the first_name plus the last_name, with a space in between.
        """
        full_name = '%s %s' % (self.first_name, self.last_name)
        return full_name.strip()

    def get_short_name(self):
        "    Returns the short name for the user."
        return self.first_name

    def _create_user(self, username, email, password, **extra_fields):
        """
        Creates and saves a User with the given …
Run Code Online (Sandbox Code Playgroud)

python django

2
推荐指数
1
解决办法
1278
查看次数