目次 |
---|
・ビュー ・TextビューとButton |
package jp.co.confrage; import android.app.Activity; import android.os.Bundle; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; public class Android001Activity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); setContentView(ll); TextView tv1 = new TextView(this); tv1.setText("Hello Android!"); Button bt1 = new Button(this); bt1.setText("Button1"); ll.addView(tv1); ll.addView(bt1); } }上記を実行すると以下のようにボタンが生成されているのがわかります。