android.widget.Button を使用します。
Buttonを使ったサンプル
■ソースコード
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.button_layout);
// ボタンをクリックした場合のイベントを設定
findViewById(R.id.sample_btn).setOnClickListener(this);
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.sample_btn) {
// ボタンが押されたイベント
}
}
■レイアウト
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:padding="0dp" >
<Button
android:id="@+id/sample_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="ぼたん" />
</FrameLayout>
0 件のコメント:
コメントを投稿