小编Mic*_*ael的帖子

android.widget.Button无法强制转换为android.widget.EditText

开发我的第一个Android计算器应用程序,我成功通过意图传递答案来更新新活动中的TextView,但这需要用户点击返回执行另一个计算.我正在尝试使doCalculation按钮更新MainActivity中的简单TextView并获取错误:

06-22 11:08:17.318:E/AndroidRuntime(31328):引起:java.lang.ClassCastException:android.widget.Button无法强制转换为android.widget.EditText

这是我的代码:

/** Called when the user clicks the Calculate! button */
public void doCalculation(View view) {
    // Do something in response to button
    int answerInt;
    String answer;
    EditText numberOne = (EditText) findViewById(R.id.number1);
    EditText numberTwo = (EditText) findViewById(R.id.number2);
    int numberOnee = Integer.parseInt(numberOne.getText().toString());
    int numberTwoo = Integer.parseInt(numberTwo.getText().toString());
    answerInt = numberOnee * numberTwoo;
    answer = Integer.toString(answerInt);

    TextView homeAnswerView = (TextView) findViewById(R.id.homeAnswerView);
    homeAnswerView.setTextSize(40);
    homeAnswerView.setText(answer);
}
Run Code Online (Sandbox Code Playgroud)

作为参考,这里是成功启动新活动的代码:

// Called when the user clicks the Calculate! button
public void doCalculation(View view) {
    // …
Run Code Online (Sandbox Code Playgroud)

android

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

如何将 Google One Tap 登录与 django-allauth 集成?

如何将 Google One Tap 登录体验与 django-allauth 集成?

  1. django-allauth 是集成的,非常适合简单的用户名/密码登录。
  2. 我拥有 Google OneTap 更好的用户体验,可以识别用户经过身份验证的 Google 帐户,并提供继续操作,向 Django 发送 JWT 身份验证令牌。
  3. 尝试找到最简单/最干净的方法来使用 OneTap 令牌注册新用户帐户并将其视为经过身份验证。

感谢任何建议。

参考文献:

django-allauth google-identity

5
推荐指数
1
解决办法
1209
查看次数

标签 统计

android ×1

django-allauth ×1

google-identity ×1