EditText problems


  1. neosephiroth86

    neosephiroth86 New Member

    hi!I need to create in Android a number of layouts for my input(every layout will be the input to manage the resource of a single process,and I will have a non finite number of them).the input layout code will be called recursively.I have a problem,the program crashes if I change the edittext field in a iteration superior to 1,I simplified my code to try to find the problem.By clicking the button "avanti" I can simply go to the main layout and the out layout.
    As you can see if a edit the edittext in the next layout (after I press the button) it shows me that input right,if I try to change it in my next iteration the program crashes.Can u help me?thanks

    Code (Text):
    1. package com.test;
    2.  
    3. import android.app.Activity;
    4. import android.os.Bundle;
    5. import android.view.View;
    6. import android.widget.Button;
    7. import android.widget.EditText;
    8. import android.widget.TextView;
    9. import java.util.Vector;
    10.  
    11. public class test extends Activity {
    12.  
    13. EditText quantita;
    14.  
    15. public void onCreate(Bundle savedInstanceState) {
    16. super.onCreate(savedInstanceState);
    17. inizio();
    18.  
    19. }
    20.  
    21.  
    22. public void inizio(){
    23. setContentView(R.layout.main);
    24.  
    25. Button button01 = (Button)findViewById(R.id.Button01);
    26. button01.setOnClickListener( new Button.OnClickListener(){
    27. public void onClick(View view) {
    28. quantita =(EditText)findViewById(R.id.EditText01);
    29. int quantita1=Integer.parseInt(quantita.getText().toString());
    30. setContentView(R.layout.out);
    31. TextView test=(TextView)findViewById(R.id.TextView01);
    32. test.setText(""+quantita1);
    33. Button avanti = (Button)findViewById(R.id.avanti);
    34. avanti.setOnClickListener( new Button.OnClickListener(){
    35. public void onClick(View view) {
    36. inizio();
    37.  
    38. }
    39. });
    40. }
    41.  
    42. });
    43. }
    44. }
    main.xml
    [syntax="xml"]<AbsoluteLayout android:id="@+id/AbsoluteLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"><EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/EditText01" android:layout_y="156dip" android:layout_x="109dip" android:numeric="integer" android:text="0" android:editable="true" android:enabled="true"></EditText>
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/Button01" android:layout_x="73dip" android:layout_y="282dip" android:text="avanti"></Button>

    out.xml
    <AbsoluteLayout android:id="@+id/AbsoluteLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/TextView01" android:layout_y="124dip" android:layout_x="75dip"></TextView>
    <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_x="100dip" android:layout_y="65dip" android:text="avanti" android:id="@+id/avanti"></Button>
    </AbsoluteLayout>

    Advertisement
  2. metter

    metter Active Member

    Hey

    I don't really understand what you're trying to accomplish.

    Anyways; Your code does not crash.
    Whats the error you get?

    Cheers.
  3. neosephiroth86

    neosephiroth86 New Member

    i'm just trying to navigate from a layout to another and editing an edittext.i'm not using intents or starting other activities i'm trying to keep it as simple as I can.the problem is that when i edit the edittext the program crashes.You said it doesn't crash,it's true the compiler works on the code,the avd starts normally.Only when you use it and you edit the edittext box more times going forward and reverse using the buttons it DOES CRASH.
    if you want I can make a video to let you understand better.anyway thank you very much for your time

Share This Page