0

嗨,我正在尝试开始制作一个 android 应用程序(初学者的东西),我希望用户在文本框中输入的任何内容都可以转到我拥有的文本视图,我已经通过引用所有 id 来启动我的代码并搜索了所有在互联网上,但每次我尝试它时,我都会遇到错误,有人可以帮助我使用一些可以做到这一点的简单代码。

public class BitActivity extends Activity {

EditText INPUT;
TextView byte1;

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

    INPUT = (EditText) findViewById(R.id.input);
    byte1 = (TextView) findViewById(R.id.byte1);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

  }
4

1 回答 1

0

在你做你的 findVIewById 之后把它放在你的 onCreate 中

INPUT.addTextChangedListener(new TextWatcher() {
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        byte1.setText(blah.getText());
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    }

    @Override
    public void afterTextChanged(Editable s) {
    }
});
于 2013-02-11T20:50:28.717 回答