Android toast tutorial aide ide


Tutorial on how to create android toast in aide ide,  Android toast is a small message displayed on the screen, similar to a tool tip or other similar popup notification.

Here  is a sample android toast code:
Toast.makeText(getApplicationContext(), "Malitanyo Developer", Toast.LENGTH_LONG).show();


Customize android toast:
In your java activity add this code:
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast,
(ViewGroup) findViewById(R.id.modded_toast));

TextView text = (TextView) layout.findViewById(R.id.mod_text);
text.setText("This a sample customized toast in android you can remove title if you want");

Toast toast = new Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();

Next create new xml files and name into "toast.xml" this files located to res/layout/toast.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/modded_toast"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#9F6A74AF">

<LinearLayout
android:orientation="vertical"
android:layout_height="match_parent"
android:id="@+id/botx"
android:layout_width="match_parent"
android:padding="5dp">

<TextView
android:layout_width="match_parent"
android:id="@+id/title"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:text="Customize Toast"
android:gravity="center"/>

<LinearLayout
android:orientation="horizontal"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#CC000000">

<ImageView
android:src="@drawable/ic_launcher"
android:layout_width="50dp"
android:layout_below="@id/title"
android:layout_height="50dp"
android:layout_marginRight="5dp"/>

<TextView
android:id="@+id/mod_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:layout_gravity="top|left"/>

</LinearLayout>

</LinearLayout>

</LinearLayout>

Done.

Comments

Popular posts from this blog

Implement in-app purchase in aide ide

Implement google admob interstitial ads in aide ide

Android listview with search function using aide ide

Implement google admob banner ads in aide ide

Aide ide tutorial - Add line graph


Malitanyo Developer blog & tutorial 2020
Refund Policy    Facebook Page    Google Play

Blogger.com