Home  >  Article  >  Java  >  Get Text From Input Field..

Get Text From Input Field..

Susan Sarandon
Susan SarandonOriginal
2024-09-22 14:15:11312browse

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

}

The above is the detailed content of Get Text From Input Field... For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Next goalNext article:Next goal