I'm new to Java-programming, however, I do have experience with C++ and c#. I've now taken it upon myself to start programming for Android, and for that I of course need Java. I'm using Eclipse for this. Now get this: New programming language (Java), new target platform (Android) and new environment (Eclipse). So I'm in a bit over my head. Eclipse keeps complaining about the formatting of my code, and I can't see what's wrong with it.
Below is my code, I've included in comments the errors Eclipse tells me I have.
Basically, Eclipse claims that my accolade{}- and bracket() blocks aren't complete, but I think they are. I've purposely gone to work methodically., slowly adding code (there's not much of it, as you can see) to make sure that the brackets all added up.
The error on line 16 is particularly puzzling: this piece of code was generated by Eclipse / Android Development Tools (ADT)-plugin. All I've done is change the formatting to make it clear if the brackets were complete. I think they are.
And for some weird reason, Copying and psationg tis code from Eclipse gives me code which isn't visible in the editor. For instance the top line reads:
package com.androidbook.multimedia; instead of the actual
package com.magicmojo.timelog;
I did copy some bits of code out of a androidbook-sample project, but not all of it, that's for sure, and besides: that line now reads package com.magicmojo.timelog;
package com.magicmojo.timelog; import android.app.Activity; import android.content.ContentValues; import android.content.Intent; import android.media.MediaPlayer; import android.media.MediaRecorder; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.util.Log; import android.view.View; import android.widget.Button; package com.magicmojo.timelog; import android.app.Activity; import java.util.Date; import android.os.Bundle; import android.view.View; import android.widget.Button; public class timelog extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } // Syntax error on token "}", delete this token (line 16) //insert Button-stuff here? final Button record = (Button) findViewById(R.id.Button01); //record the current Time/Date() final int MAX_I = 5; final Date[] DateListing; DateListing = new Date[MAX_I]; final int i = 0; record.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (i<MAX_I) { DateListing[i] = new Date(); i++; } //else // toast an error } };// Syntax error, insert ")" to complete Expression (Line 37) } // Syntax error, insert "}" to complete ClassBody (line 39)