简体   繁体   中英

Command button to import text to textview from edittext using Scanner?

ok so i what to develop an application that will take the text from edittext to textview with the click of button this is what i have so far kind of a noob to 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);
    }
}
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() );
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM