Help with a simple Android UI

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Help with a simple Android UI

Postby neosephiroth86 » Sun Oct 25, 2009 11:11 am

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

[syntax="java"]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>
neosephiroth86
Freshman
Freshman
 
Posts: 4
Joined: Mon Sep 28, 2009 3:22 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests