Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 10th, 2012  |  syntax: None  |  size: 0.87 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Command button to import text to textview from edittext using Scanner?
  2. package one.two;
  3.  
  4. import android.app.Activity;
  5. import android.os.Bundle;
  6. import android.view.View.OnClickListener;
  7. import android.widget.EditText;
  8. import android.widget.Button;
  9. import java.util.Scanner;
  10. public class one extends Activity {
  11. public static void main(String args[]){
  12.     Scanner what = new Scanner(System.in);
  13.     what.toString();
  14.  
  15. }  
  16.     @Override
  17.     public void onCreate(Bundle savedInstanceState) {
  18.         super.onCreate(savedInstanceState);
  19.         setContentView(R.layout.main);
  20.     }
  21. }
  22.        
  23. Button btn = findViewById(yourButtonId);
  24. btn.setOnClickListener(new OnClickListener() {
  25.  
  26.     @Override
  27.     public void onClick(View v) {
  28.         EditText txt = findViewById(yourEditTextId);
  29.         TextView txt1 = findViewById(yourTextViewId);  
  30.         txt.setText( txt.getText().toString() );
  31.     }
  32. });