Get Text From Input Field..

anooppatel

Anoop Patel

Posted on September 22, 2024

Get Text From Input Field..

Java Code

public class MainActivity extends AppCompatActivity {

    Button btn;
    TextView textView;

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

        btn = findViewById(R.id.btn);
        textView = findViewById(R.id.editText);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String input = textView.getText().toString().trim();
                TextView text = findViewById(R.id.result);
                text.setText(input);
                Log.d("View", input);
            }
        });
    }

}
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
anooppatel
Anoop Patel

Posted on September 22, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Get Text From Input Field..
androiddev Get Text From Input Field..

September 22, 2024