Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6587523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:55:41+00:00 2026-05-25T16:55:41+00:00

I am trying the tutorial notepadv2 for android. I did everything the tutorial said

  • 0

I am trying the tutorial notepadv2 for android. I did everything the tutorial said (and used only the code they gave me)and i am getting errors all over the place. Help!!!!

this is my NoteEdit.java file in /src

package com.android.demo.notepad2;

  import android.app.Activity;
   import android.os.Bundle;

  private EditText mTitleText;
  private EditText mBodyText;
   private Long mRowId;

  @Override
 protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.note_edit);

mTitleText = (EditText) findViewById(R.id.title);
mBodyText = (EditText) findViewById(R.id.body);

Button confirmButton = (Button) findViewById(R.id.confirm);

mRowId = null;
Bundle extras = getIntent().getExtras();
if (extras != null) {
    String title = extras.getString(NotesDbAdapter.KEY_TITLE);
    String body = extras.getString(NotesDbAdapter.KEY_BODY);
    mRowId = extras.getLong(NotesDbAdapter.KEY_ROWID);

    if (title != null) {
        mTitleText.setText(title);
    }
    if (body != null) {
        mBodyText.setText(body);
    }
}

confirmButton.setOnClickListener(new View.OnClickListener() {

    public void onClick(View view) {
        Bundle bundle = new Bundle();

        bundle.putString(NotesDbAdapter.KEY_TITLE, mTitleText.getText().toString());
        bundle.putString(NotesDbAdapter.KEY_BODY, mBodyText.getText().toString());
        if (mRowId != null) {
            bundle.putLong(NotesDbAdapter.KEY_ROWID, mRowId);
        }

        Intent mIntent = new Intent();
        mIntent.putExtras(bundle);
        setResult(RESULT_OK, mIntent);
        finish();
    }
});

}

this is my Notepadv2.java file in /src

     package com.android.demo.notepad2;

import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
 import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class Notepadv2 extends ListActivity {
private static final int ACTIVITY_CREATE=0;
private static final int ACTIVITY_EDIT=1;

private static final int INSERT_ID = Menu.FIRST;
private static final int DELETE_ID = Menu.FIRST + 1;

private NotesDbAdapter mDbHelper;
private Cursor mNotesCursor;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.notes_list);
    mDbHelper = new NotesDbAdapter(this);
    mDbHelper.open();
    fillData();
    registerForContextMenu(getListView());
}

private void fillData() {
    // Get all of the rows from the database and create the item list
    mNotesCursor = mDbHelper.fetchAllNotes();
    startManagingCursor(mNotesCursor);

    // Create an array to specify the fields we want to display in the list (only TITLE)
    String[] from = new String[]{NotesDbAdapter.KEY_TITLE};

    // and an array of the fields we want to bind those fields to (in this case just text1)
    int[] to = new int[]{R.id.text1};

    // Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter notes = 
            new SimpleCursorAdapter(this, R.layout.notes_row, mNotesCursor, from, to);
    setListAdapter(notes);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(0, INSERT_ID,0, R.string.menu_insert);
    return true;
}

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    switch(item.getItemId()) {
    case INSERT_ID:
        createNote();
        return true;
    }

    return super.onMenuItemSelected(featureId, item);
}

@Override
public void onCreateContextMenu(Menu menu, View v,
        ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, DELETE_ID, 0, R.string.menu_delete);
}

@Override
public boolean onContextItemSelected(MenuItem item) {
    switch(item.getItemId()) {
    case DELETE_ID:
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        mDbHelper.deleteNote(info.id);
        fillData();
        return true;
    }
    return super.onContextItemSelected(item);
}

private void createNote() {
    Intent i = new Intent(this, NoteEdit.class);
    startActivityForResult(i, ACTIVITY_CREATE);

}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {


    super.onListItemClick(l, v, position, id);
    Cursor c = mNotesCursor;
    c.moveToPosition(position);
    Intent i = new Intent(this, NoteEdit.class);
    i.putExtra(NotesDbAdapter.KEY_ROWID, id);
    i.putExtra(NotesDbAdapter.KEY_TITLE, c.getString(
            c.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
    i.putExtra(NotesDbAdapter.KEY_BODY, c.getString(
            c.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
    startActivityForResult(i, ACTIVITY_EDIT);

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    super.onActivityResult(requestCode, resultCode, intent);
    Bundle extras = intent.getExtras();

    switch(requestCode) {
    case ACTIVITY_CREATE:
        String title = extras.getString(NotesDbAdapter.KEY_TITLE);
        String body = extras.getString(NotesDbAdapter.KEY_BODY);
        mDbHelper.createNote(title, body);
        fillData();
        break;
    case ACTIVITY_EDIT:
        Long mRowId = extras.getLong(NotesDbAdapter.KEY_ROWID);
        if (mRowId != null) {
            String editTitle = extras.getString(NotesDbAdapter.KEY_TITLE);
            String editBody = extras.getString(NotesDbAdapter.KEY_BODY);
            mDbHelper.updateNote(mRowId, editTitle, editBody);
        }
        fillData();
        break;
    }

}

}

These are the two files that the errors are coming from

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:55:41+00:00Added an answer on May 25, 2026 at 4:55 pm

    NoteEdit will not compile because it has no class declaration…

    package com.android.demo.notepad2;
    
      import android.app.Activity;
       import android.os.Bundle;
    
    //missing this line:
    //public class NoteEdit extends Activity {
    
      private EditText mTitleText;
      private EditText mBodyText;
       private Long mRowId;
    
      @Override
     protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.note_edit);
    

    Without a class declaration, the parser will spit up errors all over the place, as nothing will make sense anymore.

    I am not sure if there are any errors in Notepadv2 just by looking at it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying the ASP.NET login control tutorial and everything works well. However, I
I am trying to follow Trees tutorial at: http://cslibrary.stanford.edu/110/BinaryTrees.html Here is the code I
Trying the following tutorial http://www.androidsdkforum.com/android-sdk-development/3-oauth-twitter.html i am having trouble understanding callback URL my twitter
Android twitter Trying the following tutorial for Oauth based authentication and updating user status.
I am trying to follow the Android mapping tutorial and got to this part
So I'm trying to follow this tutorial... to learn android, and I'm having a
I'm trying to understand the Activity Testing tutorial on the Android site. One of
I'm was trying a tutorial to get data to android from a MySQL database
I'm trying to follow this little tutorial , but I keep getting this exception.
I've been trying to follow this tutorial on using Google Map View in Android.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.