Hi,
I am getting an "application has stopped unexpectedly" error when I
attempt to set the text on a TextView.
I am using the code below.

It seems to be the:

mTa.setText(mTxt, TextView.BufferType.EDITABLE);

line which is causing the error.

I would be grateful is someone could assist

Thanks.


public class HelloAndroid extends Activity {

        private View mSteveView;
        private TextView mTa;
        private CharSequence mTxt = "";

   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

       //load the compiled resource into the windows default viewgroup
       setContentView(R.layout.steve_layout);

       //get a reference to the view
       View mSteveView = (RelativeLayout) findViewById
(R.id.rel_layout);

   }

   public boolean onKeyUp (int keyCode, KeyEvent event) {
         //get a reference to the textarea
           mTa = (TextView) findViewById(R.id.entry);
           mTa.setText(mTxt, TextView.BufferType.EDITABLE);
           return true;

   }

}



With the following layout XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout id="@+id/rel_layout"  xmlns:android="http://
schemas.android.com/apk/res/android"
                                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10px">

    <TextView id="@+id/label"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Type here:"/>

    <EditText id="@+id/entry"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:background="@android:drawable/
editbox_background"
              android:layout_below="@id/label"/>

    <Button id="@+id/ok"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/entry"
            android:layout_alignParentRight="true"
            android:layout_marginTop="100px"
            android:layout_marginLeft="10px"
            android:text="OK" />

    <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@id/ok"
            android:layout_alignTop="@id/ok"
            android:layout_marginTop="100px"
            android:text="Cancel" />
</RelativeLayout>



As soon as I hit one of the keys on the emulator I get the
"application has stopped unexpectedly" error. When I take out the
mTa.setText(mTxt, TextView.BufferType.EDITABLE); line there is no
error.

Is there any way see error logs, or write debug data to a log file
manually?

Thanks

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to