SORU
2 Temmuz 2012, PAZARTESİ


Android özel tost : basit bir örnek

Android programlamaya yeni başladım.Herhangi biri bana basit bir örnek android özel bir kutlama bildirim gösteren verebilir misiniz?

CEVAP
2 Temmuz 2012, PAZARTESİ


Özel tost kod aşağıda, size yardımcı olabilir.

toast.xml

<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="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="10dp" />

    <TextView android:id="@ id/text"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:textColor="#FFF" />

</LinearLayout>

MainActivity.java

LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_layout,
                               (ViewGroup) findViewById(R.id.toast_layout_root));

ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setImageResource(R.drawable.android);
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Hello! This is a custom toast!");

Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();

Ve bağlantılar da özel tost için aşağıdaki Kontrol edin

Custom Toast with Analog Clock

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Dogbert files

    Dogbert file

    12 Ocak 2012
  • Numberphile

    Numberphile

    15 EYLÜL 2011
  • sknbp

    sknbp

    16 Kasım 2006