TextView 20160806

--- MainActivity ---
import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("TextView"); setContentView(tv); } }

TextView addView 20160806 --- MainActivity --- import android.app.Activity; import android.os.Bundle; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; public class MainActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); setContentView(layout); TextView textView = new TextView(this); textView.setText("Text"); layout.addView(textView); Button button = new Button(this); button.setText("Button"); layout.addView(button); } }