// JAVA Code
package com.example.example_5_3;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
String changeTxt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
LinearLayout.LayoutParams Lpara = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
LinearLayout baseLayout = new LinearLayout(this);
baseLayout.setOrientation(LinearLayout.VERTICAL);
baseLayout.setBackgroundColor(Color.rgb(89, 146, 219));
setContentView(baseLayout, Lpara);
EditText editText = new EditText(this);
editText.setText("");
baseLayout.addView(editText);
Button btn = new Button(this);
btn.setText("버튼입니다.");
btn.setBackgroundColor(Color.MAGENTA);
baseLayout.addView(btn);
TextView txtview = new TextView(this);
txtview.setText("이것은 TextView 입니다.");
baseLayout.addView(txtview);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
changeTxt = editText.getText().toString();
txtview.setText(changeTxt);
}
});
}
}