Tuesday 15 February 2011

eclipse - print a string in EditText box Android -


I am writing a simple program to calculate the unknown from chemistry formula PV = NRT. R is a constant 8.31.

Users can input 3 pieces of data (4 possible editable text boxes) and choose whether they want to count with the radio button. I have kept an unsuccessful safe, so if the box is empty then the standard terms are used. How I calculated the answer to each case, but it did not show up in the appropriate text box.

Here is the XML layout

  & lt; relativelayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: device = "http://schemas.android.com/tools" Android: layout_width = "match_parent" Android: layout_height = "Match_parent android: paddingBottom =" @ dimen / activity_vertical_margin "Android: paddingLeft =" @ dimen / activity_horizontal_margin "Android: paddingRight =" @ dimen / activity_horizontal_margin "Android: paddingTop =" @ dimen / activity_vertical_margin "tool: reference =". Main Activity "& gt; & LT; EditText android: id =" @ + id / editText4 "Android: layout_width =" wrap_content "Android: layout_height =" wrap_content "Android: layout_alignLeft =" @ + id / editText3 "Android: layout_below = "@ + id / editText3" Android: Leaut_margintop = "27dp" Android: ems = "10" / & gt; etc. x 4 & LT; RadioGroup android: id = "@ + id / radioGroup1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignParentRight = "true" Android: layout_alignTop = "@ + id / Button1" Android: Leaut_margin right = "33dp" & gt; & LT; RadioButton android: id = "@ + id / radio0 "Android: Layout_width =" Wrap_content "Android: Layout_height =" Wrap_content "Android: checked =" true "android: text =" @ string / Pressure "/ & gt; etc. x 4 & lt; / RadioGroup & gt; & Lt; / RelativeLayout & gt;   

here is the script of the Java class:

  public void OnCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); SetContentView (R.layout.activity_main); Press = (edit text) Find VVBID (RID Edit 1 text); Find Quantity = (Editing Text) VVBIID (RID Editlet 2); Moles = (EditText) findViewById (R.id.editText3); Temperature = (edit text) Find VVBIID (RIDAditTet 4); Return; } Public Zero onClick (see) {Switch (view.getId ()) {Case R.id.button1: RadioButton pressureButton = (RadioButton) findViewById (R.id.radio0); Find Radiabutan Volume Button = (Radiobutton) VVBIID (RID.Dreamio1); Radiobutton Malsbutton = (radio button) Find VVBID (RADEADRADIO 2); Radiobutton Temperature Baiton = (radio button) Find VVBIID (RID. Radia3); Return; } Float pressure = float.parseflat (pressure.gate text) (). ToString ()); Float Volume = Float. PeerFlot (volume .gettext (.) ToString ()); Float molesn = float.parseflot (moles.getText (). ToString ()); Float temperature = float. PeerFlot (temperature .gettext (). ToString ()); // Test box to allow for empty editing if (pressuren == 0) {pressuren = 100000; } If (Volume == 0) {volumen = (float) 0.0247; } If (molesn == 0) {molesn = 1; } If (temperature == 0) {temperaturen = 298; } // To calculate the pressure if pressed (press button) () float press (= float) (silence * 8.31 * temperature) / volume; Float volumes = (float) volumeman; Float molten = (float) molson; Float synthesis = (float) temperature; } Etc. x 4   

Sorry for all the code;

I would like to display pressurists in editText1 box etc.

Any help is quite Appreciated.

Do you want to set the text of the text box? Use it:

  Pressure. Set text (yourfloatvalue.toString ());    

No comments:

Post a Comment