• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps EditText problems

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:
package com.test; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.TextView; 
import java.util.Vector; 

public class test extends Activity { 

EditText quantita; 

public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
inizio(); 

} 


public void inizio(){ 
setContentView(R.layout.main); 

Button button01 = (Button)findViewById(R.id.Button01); 
button01.setOnClickListener( new Button.OnClickListener(){ 
public void onClick(View view) { 
quantita =(EditText)findViewById(R.id.EditText01); 
int quantita1=Integer.parseInt(quantita.getText().toString()); 
setContentView(R.layout.out); 
TextView test=(TextView)findViewById(R.id.TextView01); 
test.setText(""+quantita1); 
Button avanti = (Button)findViewById(R.id.avanti); 
avanti.setOnClickListener( new Button.OnClickListener(){ 
public void onClick(View view) { 
inizio(); 

} 
}); 
} 

}); 
} 
}

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

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones