登录按钮未正确设置文本视图文本 Android

Login button not setting the textview text correctly Android

我已经为此工作了很长时间,但我不明白为什么在按下按钮时文本设置不正确。它在其他任何地方都设置正确,但不是这个地方。我试着在不同的地方移动它,但仍然没有效果。 第一个 loginSuccess.setText("Checking Credintails");不管用。其他人在让我感到困惑的代码中工作正常。对此的任何帮助都是 appreciated.The loginSuccess.setText("Checking Credintails");应该在按下按钮时调用。

这是我的 OnClick 按钮代码

login.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            loginSuccess.setText("Checking Credintails");

            //test to see if there is a connection
            ConnectionTester ct = new ConnectionTester();
            boolean online = ct.isOnline(v.getContext());
            boolean issue = false;


            Tracker longinTracker = ((AnalyticsApplication) getApplication()).getDefaultTracker();
            userName = user.getText().toString();
            passWord = pass.getText().toString();
            LoginJsonParser ljp = new LoginJsonParser();

            if(online)
            {
                try {
                    ljp.checkUsername(loginUrl, userName, passWord);
                    canLogin = ljp.returnedResult;

                } catch (IOException e) {
                    e.printStackTrace();
                }catch (NullPointerException ne)
                {
                    issue = true;
                    loginSuccess.setText("接続の問題");
                    Log.d("Null point ", "Jsonl login");
                }
                //if(userName.equals("admin") && passWord.equals("admin")0
                if(canLogin == true)
                {
                    //Write to the ShardedPreference to store for later use
                    Log.d("My user name " , userName);
                    Log.d("My Password " , passWord);
                    MySharedPerference.writeString(getApplicationContext(),MySharedPerference.USERNAME, userName);
                    MySharedPerference.writeString(getApplicationContext(),MySharedPerference.PASSWORD, passWord);
                    //build login event
                    //call this first otherwise it may not be called and wont post to the servers
                    longinTracker.send(new HitBuilders.EventBuilder()
                                    .setCategory(getString(R.string.eventCategory))
                                    .setAction(getString(R.string.loginevent))
                                    .build()
                    );
                    //Start downloaing and processing customer data
                    //Also open up the Loading screeen animation
                    loadingImage.setVisibility(View.VISIBLE);
                    loginSuccess.setText("Loging you in now");
                    donwloadCustomerData();

                }else
                {
                    if(issue != true)
                    {
                        loginSuccess.setText("パスワードが違います");
                    }else{
                        loginSuccess.setText("接続に関する問題");
                    }

                }
            }else
            {
                Intent noCon = new Intent(v.getContext(), NoConnection.class);
                startActivity(noCon);
            }

        }
    });

感谢大家的帮助。我想通了 setText() 问题是怎么回事。 我在一定程度上改变了它,所以它会改变,但 UI 在它开始从服务器下载数据之前不会更新。所以下载正在接管线程而不是让 UI 更新和更改。所以这就是为什么后来的 setText 起作用但第一个 setText 不起作用的原因。在我将所有下载放入自己的线程后,设置的文本工作正常。感谢大家对此的帮助,您的所有想法使我以新的眼光思考并解决了这个问题。再次感谢你。