2013-02-11 83 views
0

嗨,我想開始做一個Android應用程序(初學者的東西)和我想任何用戶輸入到文本框去我已經的textview我已經開始我的代碼引用所有的ID並搜索了所有的互聯網,但每次我嘗試它,我只是得到錯誤,可以幫助我一些簡單的代碼,可以做到這一點。與Android定時器搏鬥

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; 
} 

    } 
+0

看到http://android-developers.blogspot.ie/2007/11/stitch-in-time.html – 2013-02-11 20:24:25

+1

在哪裏你編寫的代碼來設置Textview文本並從EditText中獲取它 – AAnkit 2013-02-11 20:34:11

回答

0

將這個在你的onCreate你做你的後findVIewById

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) { 
    } 
});