Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
250 views
in Technique[技术] by (71.8m points)

string - I can't seem to enter my nested if which is supposed to affect my textview

I have a nested if that checks the content of a TextView that I have.

frameLayout.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if(event.getAction() == MotionEvent.ACTION_DOWN)
            {
                clicked = clicked + 1;
                if(clicked == 2)
                {
                    Toast.makeText(toolandmode.this, "Clicks:"+clicked, Toast.LENGTH_SHORT).show();
                    startTimer();

                    String upperbound = flowrate_up.getText().toString();
                    if(upperbound == "450")
                    {
                        Log.println(Log.VERBOSE,"CHECK","Entered teh damn if statement");
                        flowrate_down.setText("150
GPM");
                        flowrate_down.setVisibility(View.VISIBLE);
                        flowrate_down.setTextColor(Color.parseColor("#696969"));
                        flowrate_down.setTextSize(10);
                    }
                    else if(upperbound == "70")
                    {
                        Log.println(Log.VERBOSE,"CHECK","Entered teh damn if statement");
                        flowrate_down.setText("150
GPM");
                        flowrate_down.setVisibility(View.VISIBLE);
                        flowrate_down.setTextColor(Color.parseColor("#696969"));
                        flowrate_down.setTextSize(10);
                    }

                }
                else if(clicked >= 4)
                {
                    Toast.makeText(toolandmode.this, "Clicks:"+clicked, Toast.LENGTH_SHORT).show();
                    AlertMessage();
                }




            }
            return true;
        }
    });

Explaining my code

My application contains a timer, While the timer I have two text views that change over the course of the total time. Within my timer I have several stages where I use if statements to decide the amount of time in each interval and call methods there that deal with animations, change in size, change in colour for my text views. Let's call these intervals: stages.

During my first stage One text view is supposed to be large and the other small, then in the next stage they do the opposite and so on. But during my first stage, for some reason the other textview that is supposed to be small is not visible. But only during the first stage not sure why even though I call the same methods in every stage.

So the code above was supposed to deal with this problem, without the if statement the textview that I want to make small and visible appears. But since the content of my first textview is what determines what the content of the smaller textview is, I need an if statement to check the content of the 1st textview.

Which brings us to the above code, the textview I'm checking is either 450 GPM or 70 RPM. I tried checking using textview.contains("450") or textview.contains("70") and it did not work, I do not know what the problem is exactly. I tried using log messages, which made it clear the nested if statements are never entered.

question from:https://stackoverflow.com/questions/65902037/i-cant-seem-to-enter-my-nested-if-which-is-supposed-to-affect-my-textview

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...