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.layo…


This content originally appeared on DEV Community and was authored by Anoop Patel

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

}


This content originally appeared on DEV Community and was authored by Anoop Patel


Print Share Comment Cite Upload Translate Updates
APA

Anoop Patel | Sciencx (2024-09-22T04:23:27+00:00) Get Text From Input Field... Retrieved from https://www.scien.cx/2024/09/22/get-text-from-input-field/

MLA
" » Get Text From Input Field..." Anoop Patel | Sciencx - Sunday September 22, 2024, https://www.scien.cx/2024/09/22/get-text-from-input-field/
HARVARD
Anoop Patel | Sciencx Sunday September 22, 2024 » Get Text From Input Field..., viewed ,<https://www.scien.cx/2024/09/22/get-text-from-input-field/>
VANCOUVER
Anoop Patel | Sciencx - » Get Text From Input Field... [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/22/get-text-from-input-field/
CHICAGO
" » Get Text From Input Field..." Anoop Patel | Sciencx - Accessed . https://www.scien.cx/2024/09/22/get-text-from-input-field/
IEEE
" » Get Text From Input Field..." Anoop Patel | Sciencx [Online]. Available: https://www.scien.cx/2024/09/22/get-text-from-input-field/. [Accessed: ]
rf:citation
» Get Text From Input Field.. | Anoop Patel | Sciencx | https://www.scien.cx/2024/09/22/get-text-from-input-field/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.