changing the value of widgets from java class

4 messages - 1232 views

Hi all,

1-How can i change the value of agauge or textfield that are created by a xml file from the java class.

2-i want to place a lable and a textfield in one line together,in xml file i can use this code :

</container>
        <container class="formEntry" style="layout:gridlayout(2,1)">
           %CHECK_VALUE%
     <textfield id="ch_opsp" focusable="false"></textfield>
  </container> 

"

but if i want to create that in a java class how can i do it?

thanks

1:

Just give id:s to the widgets in the xml and then this should work:

  Gauge progressBar = (Gauge) screen.getWidget("progressBar");
  TextArea taStatus = (TextArea) screen.getWidget("taStatus");
   
  progressBar.setValue(50);
  taStatus.setText("Some info");

2:

Container is essentially a representation of the base Widget, so something like this should work:

  Widget w = new Widget();
  //Set w:s properties as you like
  screen.add(w);

 

### Edit: progressBox -> screen

Hi.

Thanks for reply.is "progressBox" the name of xml file and "progressBar" and "taStatus" the widgets id's?

i do that but it caused an error about progressBox.what is the problem?

Oh, sorry, i'll edit that to avoid future problems on people stumbling on this thread.

ProgressBox is another widget in my application where the progressBar and taStatus widgets are in. You should be able to replace progressBox with screen, so that it becomes screen.getWidget(...), screen being the screen loaded from XML such as this:

screen = Kuix.loadScreen("SomeFrame.xml", null);