package com.AndroidImageToast;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class AndroidImageToast extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Toast ImageToast = new Toast(getBaseContext());
LinearLayout toastLayout = new LinearLayout(getBaseContext());
toastLayout.setOrientation(LinearLayout.HORIZONTAL);
ImageView image = new ImageView(getBaseContext());
TextView text = new TextView(getBaseContext());
image.setImageResource(R.drawable.icon);
text.setText("Hello!");
toastLayout.addView(image);
toastLayout.addView(text);
ImageToast.setView(toastLayout);
ImageToast.setDuration(Toast.LENGTH_LONG);
ImageToast.show();
}
}
Toast with image
It's a sample code to display Toast with image.
0 Response to "Toast with image"
Posting Komentar