「Android/UIボタン」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==layout/main.xml== <<nowiki />Button android:id="@+id/btn1" android:layout_width="wrap_content" android:layout_height="wrap_content" and...」) |
|||
| 行17: | 行17: | ||
// ボタン非表示(行を詰める | // ボタン非表示(行を詰める | ||
btn1.setVisibility(View.GONE); | btn1.setVisibility(View.GONE); | ||
| + | |||
| + | ==ボタンクリックイベント== | ||
| + | Button btn1 = (Button) findViewById(R.id.btn1); | ||
| + | btn1.setOnClickListener(new View.OnClickListener() { | ||
| + | public void onClick(View v) { | ||
| + | Log.i("test", "onClick"); | ||
| + | } | ||
| + | }); | ||
2016年10月21日 (金) 10:59時点における版
layout/main.xml
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ボタン1" />
ボタン無効化
// キー発行ボタン取得 Button btn1= (Button) findViewById(R.id.btn1); // ボタン無効化 // btn1.setEnabled(false);
ボタン非表示
// キー発行ボタン取得 Button btn1= (Button) findViewById(R.id.btn1); // ボタン非表示(行を詰める btn1.setVisibility(View.GONE);
ボタンクリックイベント
Button btn1 = (Button) findViewById(R.id.btn1);
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.i("test", "onClick");
}
});
