I want to create a simple program by put data in edit text to display in text view in the same activity.it is look like below image.
How can I do this? Thanks.
Advertisement
Answer
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView yourTextview = (TextView)findViewById(R.id.yourTextviewId); EditText yourEditText = (EditText)findViewById(R.id.yourTextviewId); Buton yourOkButton = (Button)findViewById(R.id.yourOkButtonId); yourOkButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { yourTextview.setText(yourEditText.getText().toString()); } }); }
Hope it helps