오호라~~요런 기능도 있네. Toast에 이미지랑 텍스트를 띄울 수 있다.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="BUTTON" />
</LinearLayout>
ex.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/icon" />
<TextView
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Toast Image Test" />
</LinearLayout>
StartAndroid.java
public class StartAndroid extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn = (Button)findViewById(R.id.button);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
LinearLayout layout = (LinearLayout)View.inflate(StartAndroid.this, R.layout.ex, null);
Toast toast = new Toast(StartAndroid.this);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
});
}
}
머 일반적인 Toast는 텍스트만 출력되어서 딱딱한 감이 있었지만..