package com.gusfree.toast;
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
public class ToastActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Button btn=new Button(this);
btn.setText("버튼");
setContentView(btn);
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
Toast toast=
Toast.makeText(getApplicationContext(), "ㅎㅎ", 0);
ImageView imageView=new ImageView(getApplicationContext());
imageView.setImageResource(R.drawable.ic_launcher);
/* 토스트에 뷰 셋팅하기 xml 통째로 넣어도 됨 */
toast.setView(imageView);
//위치 지정
toast.setGravity(Gravity.CENTER,50,50);
//여백 지정
toast.setMargin(1000, 1000);
toast.show();
}
});
}
}