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();
			}
		});
	}
}



'Android > 2012.04월 강좌' 카테고리의 다른 글

안드로이드 어플 등록 과정  (0) 2012.05.18
13일차 Font  (0) 2012.05.14
12일차 SocketServer 2 (Client,Server C->C)  (0) 2012.05.11
11일차 SocketServer (Client,Server C->S, S->C)  (0) 2012.05.10
11일차 Json  (0) 2012.05.10

+ Recent posts