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;
    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;
    11. public class test extends Activity {
    13. EditText quantita;
    15. public void onCreate(Bundle savedInstanceState) {
    16. super.onCreate(savedInstanceState);
    17. inizio();
    19. }
    22. public void inizio(){
    23. setContentView(R.layout.main);
    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();
    38. }
    39. });
    40. }
    42. });
    43. }
    44. }
    [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>

    <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>

  2. metter

    metter Active Member


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

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

  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