티스토리 뷰
// main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageButton
android:id="@+id/ImgBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src = "@drawable/icon"
android:text="@string/hello"
/>
</LinearLayout>
// ImgButton.java
package pkg.ImgButton;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;
public class ImgButton extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton imgbtn = (ImageButton)findViewById(R.id.ImgBtn);
imgbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ImgButton.this, "Image Button Clicked", Toast.LENGTH_SHORT).show();
}
});
}
}
'Android > Android Studio' 카테고리의 다른 글
동그란 Progress (0) | 2019.04.04 |
---|---|
파일 입출력 (0) | 2019.04.04 |
내부 스레드 & 핸들러 (0) | 2019.04.04 |
외부 스레드 & 핸들러 (0) | 2019.04.04 |
메모 - 데이터 베이스 사용 (0) | 2019.04.04 |
- Total
- Today
- Yesterday