[[戻る>Android GUI部品]]

~
*ボタンの表示 [#wd988f5b]

#ref(button.gif);

*ボタンの属性 [#md685236]

  [[Buttonの属性>Android Buttonの属性]]

~
**ボタンを配置&クリック認識をさせる際のフォーマット [#td0adbb6]

 import android.app.Activity;
 import android.os.Bundle;
 import android.widget.*;
 import android.view.*;
 import android.view.View.*;
 
 public class TestTest extends Activity implements OnClickListener{
 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
        // ボタンがクリックされた時に呼び出されるコールバックを登録
        Button button = (Button) findViewById(R.id.Button01);
        button.setOnClickListener(this);
    }
 
    public void onClick(View v) {
        // ボタンがクリックされた時に呼び出される
        Button button = (Button) v;
    }
 }

**ボタンを配置&クリック認識をさせる際のフォーマット(直書きの場合) [#td0adbb6]
 import android.app.Activity;
 import android.os.Bundle;
 import android.widget.Button;
 
 public class Test extends Activity {
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
         Button button = new Button(this);
         button.setText("button");
         setContentView(button);
     }
 }


*参考 [#a3c90ec3]

  [[日本Androidの会>http://android.siprop.org/index.php?%CA%D9%B6%AF%B2%F1%2F%A5%DC%A5%BF%A5%F3%A4%F2%A4%C4%A4%AF%A4%C3%A4%C6%A4%DF%A4%E8%A4%A6]]



~
~
[[戻る>Android GUI部品]]

Front page   New List of pages Search Recent changes   Help   RSS of recent changes