Extension creating doubt

what is the error and what you want ??

i want to add the background colour ,text colour,custom toast (image+text)to my toast
but here i have a problem i neither know the packages name i need to import nor the code
so here i need your help

can some one solve the issue

these to web page i referred

Android Examples – 1 Dec 15

Change Toast message background color in android - Android Examples

Change Toast message background color in android.Set different background color and modify toast using xml view programmatically.setBackgroundResource.



How can i change default toast message color and background color in android?

android, android-toast

asked by Saranya on 04:27AM - 02 Jul 15 UTC

and i think the answer is there
but still i dont understand how to implement it in my app

To change the Background color use this code.

Toast toast = Toast.makeText(context, Message, Toast.LENGTH_LONG);   

Imports you need

import android.view.View;
import android.widget.Toast;

thanking you a lot i will try ,i will credit you always my friend :star_struck:

but but :cry:

i coded this @AryanGupta

import android.content.Context;
import android.util.Log;
import com.google.appinventor.components.annotations.;
import com.google.appinventor.components.runtime.
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.AndroidViewComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;
import android.widget.Toast;
import android.view.View;
import android.content.Context;
import android.view.Gravity;

@DesignerComponent(version = 1, description = “This Extension was created with the AppyBuilder Code Editor.
” +
“Create your own here:
category = ComponentCategory.EXTENSION,
nonVisible = true, iconName = “http://appyBuilder.com/extensions/icons/extension.png”)
@SimpleObject(external = true)
public class Simple_toast extends AndroidNonvisibleComponent {
private ComponentContainer container;
* @param container container, component will be placed in
public Simple_toast(ComponentContainer container) {
this.container = container;

@SimpleFunction(description = “Show toast message,give xaxis,yaxis,message”)
public void ShowToastMessage(String message, int x, int y) {
Toast toast = Toast.makeText(container.$context(),message,Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, x, y);

i did this in appy builder and got this

my error.txt (4.0 KB)
help please

You will need to import the Color class as well:
As you are using one if its enums/constants here:

Note: for questions about extension development, you should ask in the app Inventor community:

The #discuss category is for discussion about kodular.

thanks a lot

1 Like

can i create this topic there and delete here

please follow the naming conventions


i am getting this error

it is a code not a error

any way i aldready did this coding you can find all here

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

ads are not relevant to this topic post it in new topic its not relevant to toast

I think your compiler doesn’t support Android imports

so, what should i do?

The code is for extension ?? If yes, then don’t worry it will work in extensions.

when i am compiling it shows package does not exist

How you compile the code ?? Do not compile the code in your compiler . Just copy the code and paste it in a new notepad java file and then, save the file to your package. After that you can run ant extensions in Apache ant

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.