使用Scanner从edittext导入文本到textview的命令按钮?

时间:2011-06-26 18:13:52

标签: java android eclipse sdk

好吧所以我要开发一个应用程序,通过点击按钮将文本从edittext转到textview,这就是我到目前为止对java的一个菜鸟

package one.two;

import android.app.Activity;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Button;
import java.util.Scanner;
public class one extends Activity {
public static void main(String args[]){
    Scanner what = new Scanner(System.in);
    what.toString();

}   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

1 个答案:

答案 0 :(得分:1)

Button btn = findViewById(yourButtonId);
btn.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        EditText txt = findViewById(yourEditTextId);
        TextView txt1 = findViewById(yourTextViewId);  
        txt.setText( txt.getText().toString() );
    }
});