A little problem for a newb?

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

A little problem for a newb?

Postby skip » Tue Oct 20, 2009 8:28 am

Hi there,

in the first place i apologize for my bad english.


I got a problem with doing a tutorial i found on the net

http ://www.dreamincode.net /forums/showtopic130264.htm THE LINK TO THE TUTORIAL

My eclipse now forces me do delete the second "@Override".
The error is "The method onClick(View) of type nonsens must override a superclass method" and the quickfix says
"Remove '@Override' annotation".

I tried to delete the @Override and start the app with the emulator but then there is another error saying
"Sorry! The Application Nonsens (process de.fweber.nonsens) has stopped unexpectedly. Please try again later".

In eclipse there are two markers "Java Exception Breakpoint". What's it about this things?


Maybe there is someone out there who can help me.
Don't forgett i'm absolutely new in this, so maybe you have to explain it a little bit more ^^


thx Skip
skip
Freshman
Freshman
 
Posts: 4
Joined: Tue Oct 20, 2009 8:06 am

Top

Postby SlumberMachine » Tue Oct 20, 2009 10:20 am

It would probably help if you posted the code you have so far since it's possible it's something simple like a capitalized letter that shouldn't be capitalized or vice versa. It's kind of hard to tell what the problem could be from the details given.

Try doing a ctrl-shift-o to make sure you have the correct imports in eclipse, and look over the lines and make sure you have all of it copied correctly. It really sounds to me that your line:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onClick(View v) {
  2.  
  3.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
has something written wrong.
SlumberMachine
Developer
Developer
 
Posts: 39
Joined: Tue Feb 24, 2009 9:00 pm

Postby skip » Tue Oct 20, 2009 10:38 am

Here is the code i have writen

nonsens.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package de.fweber.nonsens;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.content.pm.ActivityInfo;
  8.  
  9. import android.os.Bundle;
  10.  
  11. import android.view.Window;
  12.  
  13. import android.widget.TextView;
  14.  
  15. import android.widget.EditText;
  16.  
  17. import android.widget.Button;
  18.  
  19. import android.view.View;
  20.  
  21. import android.view.View.OnClickListener;
  22.  
  23.  
  24.  
  25. public class nonsens extends Activity implements OnClickListener {
  26.  
  27.     /** Called when the activity is first created. */
  28.  
  29.     @Override
  30.  
  31.     public void onCreate(Bundle savedInstanceState) {
  32.  
  33.         super.onCreate(savedInstanceState);
  34.  
  35.         requestWindowFeature(Window.FEATURE_NO_TITLE);
  36.  
  37.         this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  38.  
  39.        
  40.  
  41.         Button b = (Button)this.findViewById(R.id.btn_confirm);
  42.  
  43.         b.setOnClickListener(this);
  44.  
  45.     }
  46.  
  47.     @Override
  48.  
  49.     public void onClick(View v){
  50.  
  51.          TextView tv = (TextView)this.findViewById(R.id.tv_welcome);
  52.  
  53.          EditText et = (EditText)this.findViewById(R.id.txt_name);
  54.  
  55.          
  56.  
  57.          String text = "Hallo" + et.getText().toString() + ".\n\n";
  58.  
  59.          text += "Willkommen bei Nonsens";
  60.  
  61.          
  62.  
  63.          tv.setText(text);
  64.  
  65.     }
  66.  
  67. }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


main.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:orientation="vertical"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent"
  10.  
  11.    >
  12.  
  13.    
  14.  
  15.     <TextView
  16.  
  17.    android:layout_width="fill_parent"
  18.  
  19.    android:layout_height="wrap_content"
  20.  
  21.    android:text="Gib deinen Namen ein:"
  22.  
  23.    />
  24.  
  25.    
  26.  
  27.     <EditText
  28.  
  29.    android:layout_width="fill_parent"
  30.  
  31.    android:layout_height="wrap_content"
  32.  
  33.    android:id="@+id/txt_name"
  34.  
  35.    />
  36.  
  37.    
  38.  
  39.     <Button
  40.  
  41.    android:layout_width="fill_parent"
  42.  
  43.    android:layout_height="wrap_content"
  44.  
  45.    android:id="@+id/btn_confirm"
  46.  
  47.    android:text="Bestätigen"
  48.  
  49.    />
  50.  
  51.    
  52.  
  53.     <TextView
  54.  
  55.    android:layout_width="fill_parent"
  56.  
  57.    android:layout_height="wrap_content"
  58.  
  59.    android:id="@+id/tv_welcome"
  60.  
  61.    />
  62.  
  63.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
skip
Freshman
Freshman
 
Posts: 4
Joined: Tue Oct 20, 2009 8:06 am

Postby qlimax » Tue Oct 20, 2009 10:47 am

I think that you have a problem with your developing ambient setup :?
try to install the lastest jdk from java.sun.com.
then change the compiler compilance level setting under eclipse: project->properties->java compiler to 6
(the numer of the version of the jdk you installed)

the @Override is in the right place.

let me know.. see you
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby skip » Tue Oct 20, 2009 11:21 am

Hey thanks, that worked.
The error has gone and the "@Override" can stay in that case ^^

but after launching the emulator the app still won't run.

here the infos from the LogCat

10-20 10:08:08.686: INFO/ActivityManager(567): Start proc de.fweber.nonsens for activity de.fweber.nonsens/.nonsens: pid=702 uid=10020 gids={}
10-20 10:08:08.706: DEBUG/dalvikvm(695): VM cleaning up
10-20 10:08:08.796: DEBUG/dalvikvm(695): LinearAlloc 0x0 used 637060 of 4194304 (15%)
10-20 10:08:09.277: DEBUG/AndroidRuntime(702): Shutting down VM
10-20 10:08:09.277: WARN/dalvikvm(702): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
10-20 10:08:09.277: ERROR/AndroidRuntime(702): Uncaught handler: thread main exiting due to uncaught exception
10-20 10:08:09.297: ERROR/AndroidRuntime(702): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.fweber.nonsens/de.fweber.nonsens.nonsens}: java.lang.NullPointerException
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at android.app.ActivityThread.access$1800(ActivityThread.java:112)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at android.os.Handler.dispatchMessage(Handler.java:99)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at android.os.Looper.loop(Looper.java:123)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at android.app.ActivityThread.main(ActivityThread.java:3948)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at java.lang.reflect.Method.invokeNative(Native Method)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at java.lang.reflect.Method.invoke(Method.java:521)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at dalvik.system.NativeStart.main(Native Method)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): Caused by: java.lang.NullPointerException
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at de.fweber.nonsens.nonsens.onCreate(nonsens.java:22)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
10-20 10:08:09.297: ERROR/AndroidRuntime(702): ... 11 more

i just don't get it...
skip
Freshman
Freshman
 
Posts: 4
Joined: Tue Oct 20, 2009 8:06 am

Postby qlimax » Tue Oct 20, 2009 12:29 pm

hey :)

you missed

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(R.layout.main);
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


just the first method to call in the onCreate method... this method tells the Activity what's the layout you will use for it.


cya :run:
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Top

Postby skip » Tue Oct 20, 2009 1:04 pm

BIG THANKS

it's working fine :D


now i have try different stuff ^^

cya and thx again
skip
Freshman
Freshman
 
Posts: 4
Joined: Tue Oct 20, 2009 8:06 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 14 guests