How to click or tap on a TextView text

后端 未结 8 1671
無奈伤痛
無奈伤痛 2020-11-27 09:52

I know this is so easy (doh...) but I am looking for a way to run a method on tapping or clicking a TextView line of text in an Android App.

I keep thinking about bu

8条回答
  •  执笔经年
    2020-11-27 10:21

    This may not be quite what you are looking for but this is what worked for what I'm doing. All of this is after my onCreate:

    boilingpointK = (TextView) findViewById(R.id.boilingpointK);
    
    boilingpointK.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if ("Boiling Point K".equals(boilingpointK.getText().toString()))
                boilingpointK.setText("2792");
            else if ("2792".equals(boilingpointK.getText().toString()))
                boilingpointK.setText("Boiling Point K");
        }
    });
    

提交回复
热议问题