Re: a layout scroling texts box array

386 views
Skip to first unread message
Message has been deleted

Jorge Ramirez

unread,
Oct 13, 2014, 5:05:22 PM10/13/14
to androi...@googlegroups.com
Hi Nelson, 
I would recommend you to add the code directly here using the "Highlight code syntax" button: 

It is tedious to have to go to an external site to get a dropbox download of a zip file with a js file that I have to open, copy and paste to android script. It's much, much easier for me to just copy the text here and paste it back to DroidScript.

You can put anything you want inside a Scroller, you put the scroller then inside you put a layout and inside that layout you can put Textfields, TexEdit fields, images or anything you like! you just have to add them to the layout that's inside the scroller.

Cheers!


nelson ze

unread,
Oct 13, 2014, 5:30:34 PM10/13/14
to androi...@googlegroups.com
 a scroll layout im want to change a list box by list of scroll using text boxes  Client ref. And client name in a layout scroll it is possible?

You need to add same clients to test if 
my app to add clients

My app to list clients in this im want to change the list box by a list of text boxes in a scroll layout



https://www.dropbox.com/s/g822uhbtay1inmo/clients.zip?dl=0


Sory and thanks

nelson ze

unread,
Oct 13, 2014, 5:39:39 PM10/13/14
to androi...@googlegroups.com

// app to add clients;
var idd=" ";
var namee=" ";
var nn="\0\n"
//Called when application is started.
function OnStart()
{
//Create a layout with objects vertically centered.
lay = app.CreateLayout( "linear", "VCenter,FillXY" );

edt = app.CreateTextEdit( "", 0.8, 0.4 );
edt.SetTextColor( "#ff000000" );
edt.SetBackColor( "#ffaa00ff" );
lay.SetBackColor( "#ffaa00ff" );


edt2 = app.CreateTextEdit( "", 0.8, 0.1);
edt2.SetTextColor( "#ff000000" );
edt2.SetBackColor( "#ffaa00ff" );


edt3 = app.CreateText( "client id", 0.8,0.1);
edt3.SetTextColor( "#ff000000" );
edt3.SetBackColor( "#ffaa00ff" );

lay.AddChild( edt3 );



lay.AddChild( edt2 );




edt4 = app.CreateText( "client name", 0.8,0.1);
edt4.SetTextColor( "#ff000000" );
edt4.SetBackColor( "#ffaa00ff" );

lay.AddChild( edt4 );




lay.AddChild( edt );




btn2 = app.CreateButton( "add client" );
btn2.SetOnTouch( lload );
lay.AddChild( btn2 );



//Add layout to app.
app.AddLayout( lay );


}


function lload ()
{
i=edt2.GetText()+idd;
n=edt.GetText()+namee;
i=i.slice(0,11)+nn;
n=n.slice(0,30)+nn;
n=i+n;
app.WriteFile("/sdcard/clients.dat",n,"Append");
app.Alert ("client saved");
}


Jorge Ramirez

unread,
Oct 13, 2014, 5:40:20 PM10/13/14
to androi...@googlegroups.com
Check out the example called "Scroller" on the Wifi IDE:

I'll post it here:

function OnStart()
{
    //Create the main layout.
    lay = app.CreateLayout( "linear", "FillXY" );    
    
    //Create a full screen scroller
    var scroll = app.CreateScroller( 1.0, 1.0 );
    lay.AddChild( scroll );
 
    //Create a layout inside scroller.
    layScroll = app.CreateLayout( "Linear", "Left" );
    scroll.AddChild( layScroll );
    
    //Create an image twice the screen size.
    img = app.CreateImage( "/Sys/Img/Hello.png", 2.0, 2.0 );
    layScroll.AddChild( img );

nelson ze

unread,
Oct 13, 2014, 5:43:37 PM10/13/14
to androi...@googlegroups.com

var nn="\0\n"
//Called when application is started.
function OnStart()
{
//Create a layout with objects vertically centered.
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
txt=app.ReadFile("/sdcard/clients.dat");
var arr=txt.split(nn);
var data="";
for (i=0;i<arr.length;i++){
data += arr[i]+",";
}
data+=":null";
lst = app.CreateList( data, 1, 1, "RoseGrad" );
lst.SetTextColor1( "#ff555558");
lst.SetTextColor2( "#ff555558" );
lst.SetTextMargins( 0.04, 0, 0, 0 );
lay.AddChild( lst );


lay.SetBackColor( "#ffaa00ff" );

nelson ze

unread,
Oct 13, 2014, 5:46:36 PM10/13/14
to androi...@googlegroups.com
Im want to use text boxes not images.thanks

Jorge Ramirez

unread,
Oct 13, 2014, 5:54:07 PM10/13/14
to androi...@googlegroups.com
You can use whatever control you want, the image is just an example!

nelson ze

unread,
Oct 13, 2014, 6:25:58 PM10/13/14
to androi...@googlegroups.com
Thanks.

nelson ze

unread,
Oct 16, 2014, 2:18:18 PM10/16/14
to androi...@googlegroups.com

Jorge Ramirez

unread,
Oct 16, 2014, 3:54:38 PM10/16/14
to androi...@googlegroups.com
Great, I made a couple of changes to make it a little nicer:

function OnStart() {
    //Create the main layout. 
    lay = app.CreateLayout("linear", "FillXY");

    //Create a full screen scroller 
    var scroll = app.CreateScroller(1.0, 1.0);
    lay.AddChild(scroll);

    //Create a layout inside scroller. 
    layScroll = app.CreateLayout("Linear", "Left");
    scroll.AddChild(layScroll);
    scroll.SetBackColor("#ffff0000");
    //Create an image twice the screen size. 
    var a = 0;
    var txt = Array();
    for (a = 0; a < 40; a++) {

        txt[a] = app.CreateText("item " + a, 1, -1, "Left"); //this make the text full widht
        txt[a].SetPadding(0.03, 0, 0, 0); //this move it a little from the left edge
        txt[a].SetMargins(0,0,0,0.01); //this separates from the following text
        txt[a].SetTextColor("#ff000000");
        txt[a].SetTextSize(22);


        layScroll.AddChild(txt[a]);
    }

    //Add layout to app.     
    app.AddLayout(lay);
}

Try to post your code this way on the future!

nelson ze

unread,
Oct 16, 2014, 9:40:57 PM10/16/14
to androi...@googlegroups.com
Thanks.

nelson ze

unread,
Oct 17, 2014, 8:03:04 AM10/17/14
to androi...@googlegroups.com

nelson ze

unread,
Oct 17, 2014, 8:04:42 AM10/17/14
to androi...@googlegroups.com
var m="";
function OnStart() {    
//Create the main layout.     
lay = app.CreateLayout("linear", "FillXY");
  //Create a full screen scroller    
 var scroll = app.CreateScroller(1.0, 1.0);   
 scroll.SetBackGradient("#ffff0000","#ffff4444","#ffff8888");
  
 lay.AddChild(scroll);
    //Create a layout inside scroller.   
  layScroll = app.CreateLayout("Linear", "Left");    scroll.AddChild(layScroll);    
  //Create an image twice the screen size.     var a = 0; 
   var txt = Array();  
  for (a = 0; a < 20; a++) {
        txt[a] = app.CreateButton("item " + a, 1, -1, "Left"); //this make the text full widht   
     txt[a].SetPadding(0.03, 0, 0, 0);

 //this move it a little from the left edge   
     txt[a].SetMargins(0,0,0,0.01);
 //this separates from the following text    
 txt[a].SetBackGradient("#ffff0000","#ff880000","#ffff8888");
  
//txt[a].SetBackColor("#ffff0000");
    txt[a].SetTextColor("#ff000000");   
     txt[a].SetTextSize(22);
txt[a].SetOnTouch( t1);

        layScroll.AddChild(txt[a]);
    }
    //Add layout to app.         
app.AddLayout(lay);}


function t1(){
tt=app.GetLastButton();
m=tt.GetText();
app.ShowPopup( m);

}


Reply all
Reply to author
Forward
0 new messages