Thanks for pointing that out! But the same problem is still there. The
app crashes, even closes itself before I click the "force close"
button. Logcat doesn't give error msg. Any idea?

On Jul 13, 12:12 am, YuviDroid <[email protected]> wrote:
> Before using course_main you should initialize it:
> course_main = (LinearLayout) findViewById(R.id.course_main);
>
> On Mon, Jul 12, 2010 at 11:13 PM, theresia freska <[email protected]
>
>
>
> > wrote:
> > Hello,
>
> > I'm using Android API 8, AVD 2.2. I'm trying to add simple view
> > programmatically, but everytime I try to run it in the simulator, the
> > app crashes. It gives me error msg "the app xxx has stopped
> > unexpectedly" with the "force close" button. When I comment this code,
> > the app works fine. Can anyone give me a hint on where I code wrong?
> > Thanks!
>
> > course.xml
>
> > <LinearLayout
> >        xmlns:android="http://schemas.android.com/apk/res/android";
> >        android:id="@+id/course_main"
> >        android:layout_width="wrap_content"
> >        android:layout_height="wrap_content">
> > </LinearLayout>
>
> > Course.java
>
> > public class Course extends Activity {
>
> >        LinearLayout course_main;
>
> >        public void onCreate(Bundle savedInstanceState){
> >                super.onCreate(savedInstanceState);
> >                setContentView(R.layout.course);
>
> >                TextView tv = new TextView(this);
> >                tv.setText("Hello");
>
> >                course_main.addView(tv);
> >        }
>
> > LogCat
>
> > 07-12 20:24:07.966: WARN/ActivityManager(66): Launch timeout has
> > expired, giving up wake lock!
> > 07-12 20:24:13.836: DEBUG/dalvikvm(126): GC_EXPLICIT freed 816
> > objects / 43216 bytes in 264ms
> > 07-12 20:28:28.046: DEBUG/SntpClient(66): request time failed:
> > java.net.SocketException: Address family not supported by protocol
> > 07-12 20:36:19.847: DEBUG/SntpClient(66): request time failed:
> > java.net.SocketException: Address family not supported by protocol
> > 07-12 20:49:45.127: DEBUG/SntpClient(66): request time failed:
> > java.net.SocketException: Address family not supported by protocol
> > 07-12 20:54:45.137: DEBUG/SntpClient(66): request time failed:
> > java.net.SocketException: Address family not supported by protocol
> > 07-12 20:58:31.656: DEBUG/KeyguardViewMediator(66): pokeWakelock(5000)
> > 07-12 20:58:31.876: INFO/ActivityManager(66): Displayed activity
> > de.ifgi.lbs/.RoomFinder: 2073293 ms (total 2073293 ms)
> > 07-12 20:58:32.326: INFO/ARMAssembler(66): generated
> > scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at
> > [0x2e29b0:0x2e2abc] in 23259049 ns
> > 07-12 20:58:32.486: INFO/ARMAssembler(66): generated
> > scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at
> > [0x29dca8:0x29de70] in 5497314 ns
> > 07-12 20:58:36.146: WARN/KeyCharacterMap(307): No keyboard for id 0
> > 07-12 20:58:36.146: WARN/KeyCharacterMap(307): Using default keymap: /
> > system/usr/keychars/qwerty.kcm.bin
> > 07-12 20:58:41.166: INFO/ActivityManager(66): Starting activity:
> > Intent { cmp=de.ifgi.lbs/.About }
> > 07-12 20:58:42.466: DEBUG/dalvikvm(66): GC_FOR_MALLOC freed 11952
> > objects / 522544 bytes in 750ms
> > 07-12 20:58:42.496: WARN/WindowManager(66): No window to dispatch
> > pointer action 0
> > 07-12 20:58:42.516: WARN/WindowManager(66): No window to dispatch
> > pointer action 1
> > 07-12 20:58:42.516: WARN/ActivityManager(66): Activity pause timeout
> > for HistoryRecord{43f3ad48 de.ifgi.lbs/.RoomFinder}
> > 07-12 20:58:44.766: INFO/ActivityManager(66): Displayed activity
> > de.ifgi.lbs/.About: 2297 ms (total 2297 ms)
> > 07-12 20:59:01.666: INFO/ActivityManager(66): Starting activity:
> > Intent { cmp=de.ifgi.lbs/.Filter }
> > 07-12 20:59:03.886: INFO/ActivityManager(66): Displayed activity
> > de.ifgi.lbs/.Filter: 1713 ms (total 1713 ms)
> > 07-12 20:59:33.776: INFO/ActivityManager(66): Starting activity:
> > Intent { cmp=de.ifgi.lbs/.Course }
> > 07-12 20:59:43.826: WARN/ActivityManager(66): Launch timeout has
> > expired, giving up wake lock!
> > 07-12 20:59:44.288: WARN/ActivityManager(66): Activity idle timeout
> > for HistoryRecord{43f36248 de.ifgi.lbs/.Course}
> > 07-12 20:59:45.146: DEBUG/SntpClient(66): request time failed:
> > java.net.SocketException: Address family not supported by protocol
>
> > PS. I'm sorry if this is a double posting. I accidentally push the
> > "Enter" button before finish typing.
>
> > --
> > 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
> > [email protected]<android-beginners%[email protected]>
> > 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
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to