Nevermind, moved my updateDisplay(); line to within the onClick
portion. Now everything is running fine, well as intended that is :)

On Jun 15, 10:04 am, Aaron <amd2...@gmail.com> wrote:
> Thanks, fixed that, but am still unable to get the program to actually
> display the resulting calculation upon clicking the button. Here's my
> main.xml file if it helps:
>
> <?xml version="1.0" encoding="utf-8"?>
> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent">
>     <TextView
>         android:id="@+id/label"
>         android:layout_width="fill_parent"
>         android:layout_height="wrap_content"
>         android:text="First number:"/>
>     <EditText
>         android:id="@+id/entry"
>         android:layout_width="fill_parent"
>         android:layout_height="wrap_content"
>         android:background="@android:drawable/editbox_background"
>         android:layout_below="@id/label"/>
>     <TextView
>         android:id="@+id/label1"
>         android:layout_width="fill_parent"
>         android:layout_height="wrap_content"
>         android:layout_below="@id/entry"
>         android:text="Second number:"/>
>     <EditText
>         android:id="@+id/entry1"
>         android:layout_width="fill_parent"
>         android:layout_height="wrap_content"
>         android:background="@android:drawable/editbox_background"
>         android:layout_below="@id/label1"/>
>     <Button
>         android:id="@+id/ok"
>         android:layout_width="wrap_content"
>         android:layout_height="wrap_content"
>         android:layout_below="@id/entry1"
>         android:layout_alignParentRight="true"
>         android:layout_marginLeft="10dip"
>         android:text="Generate" />
>     <TextView
>         android:id="@+id/answer"
>         android:text="GCF is..."
>         android:textSize="15pt"
>         android:layout_width="fill_parent"
>         android:layout_height="wrap_content"
>         android:layout_below="@id/ok"/>
>     <TextView
>         android:id="@+id/answer1"
>         android:textSize="18pt"
>         android:layout_width="fill_parent"
>         android:layout_height="fill_parent"
>         android:layout_below="@id/answer"
>         android:text=""/>
> </RelativeLayout>
>
> On Jun 15, 9:54 am, YuviDroid <yuvidr...@gmail.com> wrote:
>
>
>
> > At this point of the code A and B are null:
>
> >  iA = Integer.parseInt(A.trim());
> >  iB = Integer.parseInt(B.trim());
>
> > The computation part should be in your onClick method.
>
> > On Tue, Jun 15, 2010 at 6:30 PM, Aaron <amd2...@gmail.com> wrote:
> > > Trying to get my first android app up and running. It's a basic GCF
> > > calculator, but I can't get it to run. Can anyone help me out?
>
> > > package com.example.GCF;
>
> > > import java.util.Arrays;
>
> > > import android.app.Activity;
> > > import android.os.Bundle;
> > > import android.view.View;
> > > import android.view.View.OnClickListener;
> > > import android.widget.Button;
> > > import android.widget.EditText;
> > > import android.widget.TextView;
>
> > > public class GCF extends Activity {
> > >        private TextView mAnswer;
> > >    private EditText mA, mB;
> > >    private Button ok;
> > >    private String A, B;
> > >    private int iA, iB;
>
> > >       �...@override
> > >    public void onCreate(Bundle savedInstanceState) {
> > >        super.onCreate(savedInstanceState);
> > >        setContentView(R.layout.main);
>
> > >        mA = (EditText) findViewById(R.id.entry);
> > >        mB = (EditText) findViewById(R.id.entry1);
> > >        ok = (Button) findViewById(R.id.ok);
> > >        mAnswer = (TextView) findViewById(R.id.answer1);
>
> > >        ok.setOnClickListener(new OnClickListener() {
> > >                public void onClick(View v)
> > >                {
> > >                        A = mA.getText().toString();
> > >                        B = mB.getText().toString();
> > >                }
> > >        });
>
> > >        // the String to int conversion happens here
> > >        iA = Integer.parseInt(A.trim());
> > >        iB = Integer.parseInt(B.trim());
>
> > >        while (iA != iB) {
> > >        int[] nums={ iA, iB, Math.abs(iA-iB) };
> > >        Arrays.sort(nums);
> > >        iA=nums[0];
> > >        iB=nums[1];
> > >        }
> > >        updateDisplay();
> > >        }
> > >        private void updateDisplay() {
> > >                mAnswer.setText(
> > >                        new StringBuilder().append(iA));
>
> > >        }
>
> > > }
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Beginners" group.
>
> > > NEW! Try asking and tagging your question on Stack Overflow at
> > >http://stackoverflow.com/questions/tagged/android
>
> > > To unsubscribe from this group, send email to
> > > android-beginners+unsubscr...@googlegroups.com<android-beginners%2Bunsubscr
> > >  i...@googlegroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-beginners?hl=en
>
> > --
> > YuviDroidhttp://android.yuvalsharon.net

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to