Java Question how can I Add XML to layout

sigster

Active Member
Licensed User
Longtime User
Hi

How can I add XML file to layout res folder , I get this error "R cannot be resolved to a variable"

Regards
Sigster
 

sigster

Active Member
Licensed User
Longtime User
Yes Java library it is

I am try if I can make custom toast to play with and use
the sample I have see online then I need to add XML to it

but when I make new java project not Android I get error

Regards
Sigster
 

barx

Well-Known Member
Licensed User
Longtime User
write your xml, put it in project\Objects\res\layout\ and make it read-only.
 

sigster

Active Member
Licensed User
Longtime User
Thanks

do I compile the library with error then put the XML in B4A res/layout folder ?
and it will work ?
 
Last edited:

sigster

Active Member
Licensed User
Longtime User
I am try to put Android Toast sample into library
in the moment I run into problem with getLayoutInflater and R.id.text

still reading on google to see if I can fix this

http://developer.android.com/guide/topics/ui/notifiers/toasts.html#Basics


B4X:
public void Show(String message)

 
 public void Show(String message)
  {

     Context context = BA.applicationContext.getApplicationContext();
     LayoutInflater inflater = getLayoutInflater();
     
     View toastRoot = inflater.inflate(R.layout.my_toast, null);
     
     Toast toast = new Toast(context);
     
     toast.setView(toastRoot);
     toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL,
             0, 0);
     toast.show();

                 
   
  }    
}


}

Regards
Sigster
 
Last edited:

sigster

Active Member
Licensed User
Longtime User
Hi

I am almost finish with this after long time and lot of google search
but setDuration don't work is it possible anyone can help me with this


B4X:
      Toast t = new Toast(context);
      t.setView(ll);
      t.setGravity(Gravity_Where, Gravity_X, Gravity_Y);
      t.setDuration(10000);
      t.show();

Regards
Sigster
 

sigster

Active Member
Licensed User
Longtime User
Finish to fix this

B4X:
    if (D_time.equals("Long")) {
          t.setDuration(Toast.LENGTH_LONG);
      }
      if (D_time.equals("Short")) {
        t.setDuration(Toast.LENGTH_SHORT);

Regards
Sigster
 

sigster

Active Member
Licensed User
Longtime User
I am not java programmer but this is more education and fun, I use ToastMessageShow but I can not change font size and color
did try custom toast in the library works well and I like it but it did take over the display and I need to wait until it go a way
so here I am after lot of search and research with toast I like

maybe to many option I already have calling the toast go out of the LCD but it is challenge to do better

do this mean your are going to upgrade ToastMessageShow with font size,color and Gravity
and I can take a break hehe


'1. title
'2. Message
'3. Title text size
'4. Title Text color
'5. Title Background color
'6. Message text size
'7. Message Text color
'8. Message Background color

Regards
Sigster
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…