public class ToastT extends Activity {
private Button b1, b2, b3;
private ImageView iv;
private LayoutInflater vi;
private View view;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b1 = (Button)findViewById(R.id.Button01);
b2 = (Button)findViewById(R.id.Button02);
b3 = (Button)findViewById(R.id.Button03);
vi = (LayoutInflater)getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
view = vi.inflate(R.layout.custom,null);
iv = (ImageView)findViewById(R.drawable.a);
/*b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.Button01: t1(); break;
case R.id.Button02: t2(); break;
case R.id.Button03: t3(); break;
}
}
public void t1(){
Toast.makeText(ToastT.this, "짧은 토스트", Toast.LENGTH_SHORT).show();
}
public void t2(){
Toast.makeText(ToastT.this, "긴 토스트", Toast.LENGTH_LONG).show();
}
public void t3(){
Toast.makeText(ToastT.this, "사용자 정의 토스트", Toast.LENGTH_SHORT).show();
}
});*/
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ToastT.this, "짧은 토스트", Toast.LENGTH_SHORT).show();
}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ToastT.this, "긴 토스트", Toast.LENGTH_LONG).show();
}
});
b3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast toast = new Toast(ToastT.this);
toast.setView(view);
toast.setDuration(Toast.LENGTH_LONG);
toast.setMargin(10.0f, 10.0f);
toast.show();
}
});
}
}
'스마트폰 > 안드로이드' 카테고리의 다른 글
다이얼로그박스 공부. (0) | 2011.05.13 |
---|---|
다이나믹 레이아웃 공부. (0) | 2011.05.13 |
Notification 공부. (0) | 2011.05.13 |
명시적 intent 공부. (0) | 2011.05.13 |
LifeCycle 공부. (0) | 2011.05.13 |