Để tạo thông báo bánh mì tùy chỉnh hiển thị hình ảnh và một số văn bản sử dụng mã java này.
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root));
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText(content);
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setImageBitmap(bmImg);
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
và file layout này
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:background="#DAAA"
>
<ImageView android:id="@+id/image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="10dp"
/>
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#FFF"
/>
</LinearLayout>
Tôi không hiểu rõ bạn muốn làm gì. Bạn có thể đăng ký một onclicklistener đến một điểm trên bạn bản đồ lớp phủ và sau đó hiển thị trong một tin nhắn bánh mì nướng. Bạn cũng có thể thêm hình ảnh vào tin nhắn chúc mừng. Tôi có thể đưa ra một số ví dụ nếu bạn chỉ định vấn đề của mình một chút. – Janusz