the application i made keeps force closing for some reaon

Put your problem here if it does not fit any of the other categories.

the application i made keeps force closing for some reaon

Postby gtang » Wed Apr 06, 2011 5:08 am

I have no clue what the problem is. I don't think there is anything wrong with my code and eclipse does not show any problems with my code. I think it's an infinite loop of while but im not that sure here is the code. the application keeps force closing though. if you could come up with a solution that would be great thanks.

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

public class gcf extends Activity {

/** Called when the activity is first created. */


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


Button solve = (Button) findViewById(R.id.widget32);







solve.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)

{ EditText d = (EditText) findViewById(R.id.number2);
EditText e = (EditText) findViewById(R.id.number1);
TextView answer = (TextView) findViewById(R.id.answer);


int a = new Integer(d.getText().toString());
int b = new Integer(e.getText().toString());
int c;
if(a == 0){
answer.setText(b);
}
else if(b==0){
answer.setText(a);;

}
else if( a >b){
c= a%b;
while(c > 0){
a=b;
b=c;
c=a%b;

}
answer.setText(b);
}
else if(b>a){
c= b%a;
while(c > 0){
b= a;
a = c;
c=b%a;

}
answer.setText(a);



}

}
});
}
}
gtang
Junior Developer
Junior Developer
 
Posts: 12
Joined: Tue Mar 08, 2011 1:14 am

Top

Re: the application i made keeps force closing for some reao

Postby gtang » Wed Apr 06, 2011 5:13 am

it force closes when i click the solve button no matter what even when there is no input though and i wrote the exact same thing as a java project except without the buttons and it worked well
gtang
Junior Developer
Junior Developer
 
Posts: 12
Joined: Tue Mar 08, 2011 1:14 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 29 guests