Commits

Jiangge Zhang  committed 999a102 Merge

合并

  • Participants
  • Parent commits f96822c, e91619e

Comments (0)

Files changed (17)

File Project/AndroidManifest.xml

 	<uses-sdk android:minSdkVersion="8" />
 
 	<application android:icon="@drawable/icon" android:label="@string/appName" android:theme="@android:style/Theme.NoTitleBar">
-	    
 		<activity android:name=".activity.MainActivity" android:label="@string/appName">
 		    <intent-filter>
 				<action android:name="android.intent.action.MAIN" />

File Project/assets/database.xml

 	"tag_id" INTEGER REFERENCES "tags" ("id"),
 	PRIMARY KEY("note_id", "tag_id")
 );
+INSERT INTO notebooks(name,uuid,created,machine_id,is_recycled) VALUES('默认笔记本','default',CURRENT_TIMESTAMP,'default',0);
 </schema>

File Project/res/layout/bookmark_manage_listview.xml

+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+	android:orientation="horizontal" android:layout_width="fill_parent"
+	android:layout_height="fill_parent"
+	android:id="@+id/bookmarkManageListview">
+	<LinearLayout android:orientation="vertical"
+		android:layout_width="fill_parent" android:layout_height="wrap_content"
+		android:layout_weight="1">
+		<LinearLayout android:id="@+id/bookmarkManageListItem"
+			    android:layout_width="fill_parent" android:layout_height="wrap_content"
+			    android:orientation="horizontal">
+		        <TextView android:id="@+id/bookmarkName" android:textSize="20dp"
+		            android:layout_width="fill_parent" android:layout_height="wrap_content"
+		            android:singleLine="true"/>
+		        <TextView  android:id="@+id/bookmarkPos" android:textSize="10dp"
+		            android:layout_width="fill_parent" android:layout_height="wrap_content"
+		            android:singleLine="true" />
+			</LinearLayout>
+	</LinearLayout>
+</LinearLayout>

File Project/res/layout/note_bookmark.xml

 		android:singleLine="true" android:hint="@string/addBookmarkHint" />
 	<LinearLayout android:id="@+id/bookmarkList"
 		android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1">
-		<TextView android:id="@+id/bookmarkName"
-			android:layout_width="fill_parent" android:layout_height="wrap_content"
-			android:singleLine="true" android:textSize="15dp" />
-		<TextView android:id="@+id/bookmarkPosition"
-			android:layout_width="fill_parent" android:layout_height="wrap_content"
-			android:singleLine="true" android:textSize="5dp" />
+		<ListView android:id="@+id/bookmarkManageList"
+	 	   android:layout_width="fill_parent" android:layout_height="wrap_content"
+		    android:scrollbars="vertical" android:clickable="true"></ListView>
 	</LinearLayout>
-
+	
 	<LinearLayout android:id="@+id/bookmarkButton"
 		android:layout_width="fill_parent" android:layout_height="wrap_content"
 		android:orientation="horizontal">

File Project/res/menu/notes_menu.xml

+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+	<item android:id="@+id/notesTab1" android:icon="@android:drawable/ic_menu_add" android:title="@string/notesTab1" />
+</menu>

File Project/res/menu/read_menu.xml

-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-	<item android:id="@+id/readTab1" android:title="@string/readTab1" />
-	<item android:id="@+id/readTab2" android:title="@string/readTab2" />
-	<item android:id="@+id/readTab3" android:title="@string/readTab3" />
-	<item android:id="@+id/readTab4" android:title="@string/readTab4" />
-	<item android:id="@+id/readTab5" android:title="@string/readTab5" />
-</menu>
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+	<item android:id="@+id/readTab1" android:title="@string/readTab1" />
+	<item android:id="@+id/readTab2" android:title="@string/readTab2" />
+	<item android:id="@+id/readTab3" android:title="@string/readTab3" />
+</menu>

File Project/res/values/main_activity.xml

 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <string name="mainTab1">登录</string>
-    <string name="mainTab2">添加笔记</string>
+    <string name="mainTab2">笔记本管理</string>
     <string name="mainTab3">设置</string>
 </resources>

File Project/res/values/note_bookmark.xml

 <resources>
     <string name="bookmarkTitle">书签</string>
     <string name="addBookmarkHint">添加书签</string>
-    <string name="bookmarkCancle">取消</string>
+    <string name="bookmarkCancle">返回</string>
     <string name="bookmarkSubmit">完成</string>
 </resources>

File Project/res/values/notes_menu.xml

+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="notesTab1">添加笔记</string>
+</resources>

File Project/res/values/read_menu.xml

 <resources>
     <string name="readTab1"> 书签</string>
     <string name="readTab2">编辑</string>
-    <string name="readTab3">分享</string>
-    <string name="readTab4">查看信息</string>
-    <string name="readTab5">更多</string>
+    <string name="readTab3">查看信息</string>
 </resources>

File Project/src/com/noodle/note/activity/BookmarkIndexActivity.java

 import java.util.HashMap;
 
 import android.app.ListActivity;
+import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
 import android.widget.ListView;
  * 笔记本书签显示页面
  * 
  * @author MarkNV
- *
+ * 
  */
 public class BookmarkIndexActivity extends ListActivity {
+	private ArrayList<HashMap<String, Object>> bookmarkList = new ArrayList<HashMap<String, Object>>();
 
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
+		initView();
+	}
 
-		ArrayList<HashMap<String, Object>> bookmarkList = new ArrayList<HashMap<String, Object>>();
+	private void initView() {
+
 		ArrayList<Bookmark> list = new ArrayList<Bookmark>();
 		BookmarkGateway bookmarkGateway = (BookmarkGateway) Session.getInstance(this).query(Bookmark.class);
 		list = (ArrayList<Bookmark>) bookmarkGateway.findAll();
 				HashMap<String, Object> contentMap = new HashMap<String, Object>();
 				contentMap.put("bookmarkName", bm.getName());
 				contentMap.put("noteName", bm.getNote().getTitle());
+				contentMap.put("noteId", bm.getNote().getId());
+				contentMap.put("startLine", bm.getLineNumber());
 				bookmarkList.add(contentMap);
 			}
-		}else{
+		} else {
 			HashMap<String, Object> noContentMap = new HashMap<String, Object>();
-			noContentMap.put("bookmarkName","暂无内容" );
-			noContentMap.put("noteName","" );
+			noContentMap.put("bookmarkName", "暂无内容");
+			noContentMap.put("noteName", "");
 			bookmarkList.add(noContentMap);
 		}
 		SimpleAdapter listAdapter = new SimpleAdapter(this, bookmarkList, R.layout.main_listview, new String[] { "bookmarkName", "noteName" }, new int[] { R.id.listNote,
 		setListAdapter(listAdapter);
 	}
 
+	/**
+	 * 单击事件监听器
+	 */
 	@Override
 	protected void onListItemClick(ListView l, View v, int position, long id) {
 		super.onListItemClick(l, v, position, id);
-		//TODO 点击事件
+		int pk = (Integer) bookmarkList.get(position).get("noteId");
+		int startLine = (Integer) bookmarkList.get(position).get("startLine");
+		Intent intent = new Intent();
+		Bundle bundle = new Bundle();
+		bundle.putInt("startLine", startLine);
+		bundle.putInt("id", pk);
+		intent.setClass(this, NoteReadActivity.class);
+		intent.putExtras(bundle);
+		startActivity(intent);
 	}
 }

File Project/src/com/noodle/note/activity/BookmarkManageActivity.java

 package com.noodle.note.activity;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+
 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
+import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.View.OnCreateContextMenuListener;
+import android.widget.AdapterView;
+import android.widget.AdapterView.AdapterContextMenuInfo;
+import android.widget.AdapterView.OnItemClickListener;
 import android.widget.Button;
 import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
 
 import com.noodle.note.R;
 import com.noodle.note.gateway.BookmarkGateway;
  * 
  */
 public class BookmarkManageActivity extends Activity {
+	private SimpleAdapter listItemAdapter;
 	private Bundle bundle;
+	private int line;
+	private int column;
+	private int noteId;
 	private EditText bookmarkEditText;
 	private Button buttonComplete;
 	private Button buttonCancle;
 	private Session session;
+	private ListView listView;
+	private ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
 
 	@Override
 	public void onCreate(Bundle savedInstanceState) {
 		buttonCancle = (Button) findViewById(R.id.bookmarkCancle);
 		buttonComplete.setOnClickListener(complete);
 		buttonCancle.setOnClickListener(cancle);
+		session = Session.getInstance(this);
 		bundle = this.getIntent().getExtras();
-		session = Session.getInstance(this);
-
+		line = bundle.getInt("line");
+		column = bundle.getInt("column");
+		noteId = bundle.getInt("noteId");
+		initViews();
+		setListeners();
 	}
 
 	/**
 
 		@Override
 		public void onClick(View v) {
-			int line = bundle.getInt("line");
-			int column = bundle.getInt("column");
-			int noteId = bundle.getInt("noteId");
+			line = bundle.getInt("line");
+			column = bundle.getInt("column");
+			noteId = bundle.getInt("noteId");
 			String bookmarkName = bookmarkEditText.getText().toString();
 			Note note = Registry.getInstance().getEntity(Note.class, noteId);
 			Bookmark bookmark = new Bookmark(note, line, column);
 			BookmarkGateway bookmarkGateway = (BookmarkGateway) session.query(Bookmark.class);
 			bookmarkGateway.create(bookmark);
 			Intent intent = new Intent();
-			int id = bundle.getInt("noteId");
-			Bundle bundle = new Bundle();
-			bundle.putInt("id", id);
 			intent.putExtras(bundle);
-			intent.setClass(BookmarkManageActivity.this, NoteReadActivity.class);
+			intent.setClass(BookmarkManageActivity.this, BookmarkManageActivity.class);
 			startActivity(intent);
+			overridePendingTransition(0, 0);
+			BookmarkManageActivity.this.finish();
 		}
 	};
 	/**
-	 * 按钮“取消“的操作设置
+	 * 按钮“返回“的操作设置
 	 */
 	OnClickListener cancle = new OnClickListener() {
 
 		@Override
 		public void onClick(View v) {
-			Intent intent = new Intent();
-			int noteId = bundle.getInt("noteId");
-			Bundle bundle = new Bundle();
-			bundle.putInt("id", noteId);
-			intent.putExtras(bundle);
-			intent.setClass(BookmarkManageActivity.this, NoteReadActivity.class);
-			startActivity(intent);
+			BookmarkManageActivity.this.finish();
 		}
 	};
 
-}
+	/** 
+	 * listView项的长按菜单
+	 */
+	OnCreateContextMenuListener longPressMenu = new OnCreateContextMenuListener() {
+
+		@Override
+		public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
+			String deleteItem = "删除";
+			/** 第二个参数为操作ID */
+			menu.add(0, 0, 0, deleteItem);
+		}
+	};
+
+	/** 
+	 * listView项的接口设置以及监听器设置
+	 */
+	public void setListeners() {
+		listItemAdapter = new SimpleAdapter(this, listItem, R.layout.bookmark_manage_listview, new String[] { "bookmarkname", "bookmarkpos" }, new int[] { R.id.bookmarkName,
+				R.id.bookmarkPos });
+		listView.setAdapter(listItemAdapter);
+		listView.setOnItemClickListener(oicl);
+		listView.setOnCreateContextMenuListener(longPressMenu);
+	}
+
+	/** 
+	 * 长按菜单操作设置
+	 */
+	@Override
+	public boolean onContextItemSelected(MenuItem item) {
+		AdapterView.AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
+		int listItemId = (Integer) listItem.get(info.position).get("bookmarkid");
+		BookmarkGateway bookmarkGateway = (BookmarkGateway) Session.getInstance(this).query(Bookmark.class);
+		Bookmark bookmark = bookmarkGateway.findById(listItemId);
+		switch (item.getItemId()) {
+		// 长按各项菜单操作 
+		case 0:
+			bookmarkGateway.delete(bookmark);
+			Bundle bundle = new Bundle();
+			bundle.putInt("line", line);
+			bundle.putInt("column", column);
+			bundle.putInt("noteId", noteId);
+
+			Intent selfintent = new Intent();
+			selfintent.putExtras(bundle);
+			selfintent.setClass(BookmarkManageActivity.this, BookmarkManageActivity.class);
+			startActivity(selfintent);
+			overridePendingTransition(0, 0);
+			BookmarkManageActivity.this.finish();
+			break;
+		}
+		return super.onContextItemSelected(item);
+	}
+
+	/** 
+	 * listView的项短按操作
+	 */
+	OnItemClickListener oicl = new OnItemClickListener() {
+		public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
+			int startLine = (Integer) listItem.get(position).get("bookmarkpos");
+			shortpress(noteId, startLine);
+		}
+	};
+
+	/** 
+	 * listview短按链接设置
+	 */
+	private void shortpress(int id, int startLine) {
+		Intent intent = new Intent();
+		Bundle bundle = new Bundle();
+		bundle.putInt("startLine", startLine);
+		bundle.putInt("id", id);
+		intent.setClass(this, NoteReadActivity.class);
+		intent.putExtras(bundle);
+		startActivity(intent);
+		BookmarkManageActivity.this.finish();
+	}
+
+	/** 
+	 * listView的内容创建
+	 */
+	private void initViews() {
+		BookmarkGateway bookmarkGateway = (BookmarkGateway) Session.getInstance(BookmarkManageActivity.this).query(Bookmark.class);
+		listView = (ListView) findViewById(R.id.bookmarkManageList);
+		ArrayList<Bookmark> bookmarkList = new ArrayList<Bookmark>();
+		// TODO 错误
+		HashMap<String, Integer> conditions = new HashMap<String, Integer>();
+		conditions.put("note_id", (Integer) noteId);
+		bookmarkList = (ArrayList<Bookmark>) bookmarkGateway.findBy(conditions);
+
+		if (!bookmarkList.isEmpty()) {
+			for (Bookmark bm : bookmarkList) {
+				HashMap<String, Object> contentMap = new HashMap<String, Object>();
+				contentMap.put("bookmarkname", bm.getName());
+				contentMap.put("bookmarkpos", bm.getLineNumber());
+				contentMap.put("bookmarkid", bm.getId());
+				listItem.add(contentMap);
+			}
+		} else {
+			HashMap<String, Object> noContentMap = new HashMap<String, Object>();
+			noContentMap.put("bookmarkname", "没有书签");
+			noContentMap.put("bookmarkpos", "空");
+			listItem.add(noContentMap);
+		}
+	}
+}

File Project/src/com/noodle/note/activity/MainActivity.java

 import android.widget.ImageButton;
 import android.widget.ImageView;
 import android.widget.RelativeLayout;
+
 import com.noodle.note.R;
 import com.noodle.note.persistent.unitofwork.Session;
 
 	private int activeBackgroundWidth;
 	private int activeBackgroundHeight;
 	private boolean isReplaced = false;
-	
+
 	private int defaultPosition;
 	private int startPosition;
 	private int endPosition = 0;
 	@Override
 	public void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
-		setContentView(R.layout.main);
 		initViews();
 		setListeners();
 		Session session = Session.getInstance(this);
 	 * 初始化视图
 	 */
 	private void initViews() {
-
+		setContentView(R.layout.main);
 		// 获得视图对象
 		tabContentLayout = (RelativeLayout) findViewById(R.id.tabContent);
 		listContentLayout = (RelativeLayout) findViewById(R.id.listContent);
 		tab1 = (ImageView) findViewById(R.id.tab1);
 		tab2 = (ImageView) findViewById(R.id.tab2);
 		tab3 = (ImageView) findViewById(R.id.tab3);
-		
 
 		// 初始化滚动背景
 		RelativeLayout.LayoutParams rl = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
 		activeBackground.setImageResource(R.drawable.icon); // TODO 修改图片
 		addButton = (ImageButton) findViewById(R.id.mainAdd);
 		searchButton = (ImageButton) findViewById(R.id.mainSearch);
-		
+
 		// 默认滚动背景位置
 		switch (defaultActiveBackgroundId) {
 		case 1:
 	/**
 	 * 绑定监听器
 	 */
-	public void setListeners() {
+	private void setListeners() {
 		tab1.setOnClickListener(onTabClickListener);
 		tab2.setOnClickListener(onTabClickListener);
 		tab3.setOnClickListener(onTabClickListener);
 
 		}
 	};
-	
+
 	/**
 	 * 运行动画
 	 */
-	public void runAnimation(View v) {
+	private void runAnimation(View v) {
 
 		boolean isRunnable = false;
 
 		}
 
 	}
-	
+
 	/**
 	 * 设置动画
 	 */
-	public void setAnimation(){
+	private void setAnimation() {
 		ImageView currentActiveBackground = (ImageView) tabContentLayout.findViewWithTag("currentActiveBackground");
 		TranslateAnimation animation = new TranslateAnimation(startPosition, endPosition - defaultPosition, 0, 0);
 		startPosition = endPosition - defaultPosition; // 重新设定起始位置
 		currentActiveBackground.bringToFront();
 		currentActiveBackground.startAnimation(animation);
 	}
-	
+
 	/**
 	 * 替换原视图
 	 */
 		relativeLayout.removeView(old);
 		ImageView iv = new ImageView(this);
 		iv.setTag("currentActiveBackground");
-		iv.setImageResource(R.drawable.icon);	// TODO 修改图片
+		iv.setImageResource(R.drawable.icon); // TODO 修改图片
 		tabContentLayout.addView(iv, rl);
 	}
+
 	/**
 	 * 替换原视图
 	 */
 			break;
 		}
 	}
-	
+
 	/**
 	 * 顶部按钮监听器
 	 */
-	
+
 	OnClickListener addButtonListener = new OnClickListener() {
 		@Override
 		public void onClick(View v) {
 	OnClickListener searchButtonListener = new OnClickListener() {
 		@Override
 		public void onClick(View v) {
-			//TODO 搜索页面
+			// TODO 搜索页面
 		}
 	};
+
 	/**
 	 * 初始化Menu
 	 */
 	@Override
 	public boolean onCreateOptionsMenu(Menu menu) {
-	    MenuInflater inflater = getMenuInflater();
-	    inflater.inflate(R.menu.main_menu, menu);
-	    return true;
+		MenuInflater inflater = getMenuInflater();
+		inflater.inflate(R.menu.main_menu, menu);
+		return true;
 	}
+
 	/**
 	 * Menu点击事件
 	 */
 	@Override
 	public boolean onOptionsItemSelected(MenuItem item) {
-	    switch (item.getItemId()) {
-	    case R.id.mainTab1:
-	    	//TODO 登录功能尚未实现
-	        return true;
-	    case R.id.mainTab2:
-	    	startActivity(new Intent().setClass(this, EditNoteActivity.class));
-	        return true;
-	    case R.id.mainTab3:
-	    	//TODO 设置功能尚未实现
-	    	return true;
-	    default:
-	        return super.onOptionsItemSelected(item);
-	    }
+		switch (item.getItemId()) {
+		case R.id.mainTab1:
+			// TODO 登录功能尚未实现
+			return true;
+		case R.id.mainTab2:
+			startActivity(new Intent().setClass(this, NotebookManageActivity.class));
+			return true;
+		case R.id.mainTab3:
+			// TODO 设置功能尚未实现
+			return true;
+		default:
+			return super.onOptionsItemSelected(item);
+		}
 	}
+
+	@Override
+	protected void onRestart() {
+		super.onRestart();
+	}
+
 }

File Project/src/com/noodle/note/activity/NoteReadActivity.java

 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
+import android.text.method.ScrollingMovementMethod;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 public class NoteReadActivity extends Activity {
 	private TextView noteContentView;
 	private int startLine = 0;
+	private int size = 24;
 	@Override
 	public void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
 		case R.id.readTab2:// MENU编辑键操作
 			editNote();
 			break;
-		case R.id.readTab3:// MENU分享键操作
-			break;
-		case R.id.readTab4:// MENU查看信息键操作
-			break;
-		case R.id.readTab5:// MENU更多键操作
+		case R.id.readTab3:// MENU查看信息键操作
 			break;
 		}
 		return true;
 	 * 跳转至书签页面
 	 */
 	private void bookmarkManage() {
-		int size = noteContentView.getLineHeight();
+		size = noteContentView.getLineHeight();
 		int scrollY = noteContentView.getScrollY();
 		int line = scrollY % size <= (size / 2) ? scrollY / size : scrollY / size + 1;
 		int column = noteContentView.getLayout().getOffsetForHorizontal(line, noteContentView.getScrollX() - noteContentView.getTotalPaddingLeft());
 		intent.putExtras(bundle);
 		intent.setClass(this, BookmarkManageActivity.class);
 		this.startActivity(intent);
-		NoteReadActivity.this.finish();
+	//	NoteReadActivity.this.finish();
 	}
 
 	private void displayContent() {
 		NoteGateway gateway = (NoteGateway) Session.getInstance(this).query(Note.class);
 		Note note = gateway.findById(pk);
 		String content = note.getArticle();
+		startLine = this.getIntent().getExtras().getInt("startLine");
 		noteContentView.setText(content);
-		noteContentView.scrollBy(0, startLine);
-		
+		noteContentView.setMovementMethod(ScrollingMovementMethod.getInstance());
+		noteContentView.scrollBy(0, startLine * size);
 	}
 	
 	private void editNote(){

File Project/src/com/noodle/note/activity/NotebookManageActivity.java

  * 
  */
 public class NotebookManageActivity extends Activity {
-	/**笔记本条目浏览的List*/
+	/** 笔记本条目浏览的List */
 	private ListView listView;
-	/**笔记本条目浏览中每个List的HashMap*/
+	/** 笔记本条目浏览中每个List的HashMap */
 	private ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
-	private NotebookGateway notebookGateway = (NotebookGateway) Session.getInstance(this).query(Notebook.class);
 
 	@Override
 	public void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.notebookmanage_main);
 		initViews();
-		setListeners();}
+		setListeners();
+	}
+
 	/** manage页面listview长按菜单 */
 	OnCreateContextMenuListener longpressmenu = new OnCreateContextMenuListener() {
-		public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
+		public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
 			String lpMenuTitle = "菜单";
 			String lpMenuItem1 = "编辑";
 			String lpMenuItem2 = "删除";
 			String lpMenuItem3 = "分享";
-			
+
 			menu.setHeaderTitle(lpMenuTitle);
-			/**第二个参数为操作ID */
+			/** 第二个参数为操作ID */
 			menu.add(0, 0, 0, lpMenuItem1);
 			menu.add(0, 1, 0, lpMenuItem2);
-			menu.add(0, 2, 0, lpMenuItem3);}	};
+			menu.add(0, 2, 0, lpMenuItem3);
+		}
+	};
 
-	/**manage页面listview项的接口设置以及监听器设置*/
+	/** manage页面listview项的接口设置以及监听器设置 */
 	public void setListeners() {
 		SimpleAdapter listItemAdapter = new SimpleAdapter(this, listItem, R.layout.notebookmanage_listview, new String[] { "notebookname", "notebookcount" }, new int[] {
 				R.id.notebookManageListName, R.id.notebookManageListCount });
 		listView.setAdapter(listItemAdapter);
 		listView.setOnItemClickListener(oicl);
-		listView.setOnCreateContextMenuListener(longpressmenu);}
+		listView.setOnCreateContextMenuListener(longpressmenu);
+	}
 
-	/**manage长按菜单操作链接*/
+	/** manage长按菜单操作链接 */
 	@Override
 	public boolean onContextItemSelected(MenuItem item) {
 		AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
 		NotebookGateway notebookListGateway = (NotebookGateway) Session.getInstance(this).query(Notebook.class);
 
 		switch (item.getItemId()) {
-		 /** 长按菜单的“编辑”操作*/
+		/** 长按菜单的“编辑”操作 */
 		case 0:
 			Intent intent = new Intent();
 			intent.setClass(NotebookManageActivity.this, NotebookManageCreatActivity.class);
 			bundle.putString("notebookName", notebookName);
 			intent.putExtras(bundle);
 			startActivity(intent);
+			NotebookManageActivity.this.finish();
 			break;
-		/** 长按菜单的“删除”操作*/
+		/** 长按菜单的“删除”操作 */
 		case 1:
-			//TODO 待修改
 			notebookListGateway.deleteById(listItemId);
-			/**变相刷新界面*/
+			/** 变相刷新界面 */
 			Intent selfintent = new Intent();
 			selfintent.setClass(NotebookManageActivity.this, NotebookManageActivity.class);
 			startActivity(selfintent);
 			NotebookManageActivity.this.finish();
 			break;
-		/** 长按菜单的“分享”操作*/
-		//TODO待实现
+		/** 长按菜单的“分享”操作 */
+		// TODO待实现
 		case 2:
-			break;}
-		return super.onContextItemSelected(item);}
+			break;
+		}
+		return super.onContextItemSelected(item);
+	}
 
-	/**Menu按键名设置*/
+	/** Menu按键名设置 */
 	@Override
 	public boolean onCreateOptionsMenu(Menu menu) {
 		String tab1Name = "新增笔记本";
 		String tab2Name = "更多";
 		menu.add(0, Menu.FIRST, 0, tab1Name);
-		menu.add(0, Menu.FIRST+1, 0, tab2Name);
-		return super.onCreateOptionsMenu(menu);	}
+		menu.add(0, Menu.FIRST + 1, 0, tab2Name);
+		return super.onCreateOptionsMenu(menu);
+	}
 
-	/**manage页面menu操作设置*/
+	/** manage页面menu操作设置 */
 	@Override
 	public boolean onOptionsItemSelected(MenuItem item) {
 		switch (item.getItemId()) {
-		/** Menu中的“新增笔记本”操作*/
+		/** Menu中的“新增笔记本”操作 */
 		case Menu.FIRST:
 			Intent intent = new Intent();
 			intent.setClass(NotebookManageActivity.this, NotebookManageCreatActivity.class);
 			startActivity(intent);
+			NotebookManageActivity.this.finish();
 			break;
-		/** Menu中的“更多”操作*/
-		//TODO 待实现
-		case Menu.FIRST+1:
-			break;}
-		return super.onOptionsItemSelected(item);}
+		/** Menu中的“更多”操作 */
+		// TODO 待实现
+		case Menu.FIRST + 1:
+			break;
+		}
+		return super.onOptionsItemSelected(item);
+	}
 
 	/** manage页面liseview短按监听 */
 	OnItemClickListener oicl = new OnItemClickListener() {
 		public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
 			int pk = (Integer) listItem.get(position).get("id");
-			shortpress(pk);	}	};
+			shortpress(pk);
+		}
+	};
 
-	/**manage页面listview短按链接设置*/
+	/** manage页面listview短按链接设置 */
 	private void shortpress(int pk) {
 		Intent intent = new Intent();
 		Bundle bundle = new Bundle();
 		bundle.putInt("id", pk);
 		intent.setClass(this, NotesDisplayActivity.class);
 		intent.putExtras(bundle);
-		startActivity(intent);}
+		startActivity(intent);
+	}
 
-
-	/**manage页面listview内容创建 */
+	/** manage页面listview内容创建 */
 	private void initViews() {
+		NotebookGateway notebookGateway = (NotebookGateway) Session.getInstance(NotebookManageActivity.this).query(Notebook.class);
 		listView = (ListView) findViewById(R.id.notebookManageMylist);
 		ArrayList<Notebook> list = new ArrayList<Notebook>();
 		list = (ArrayList<Notebook>) notebookGateway.findAll();
 				contentMap.put("notebookname", nb.getName());
 				contentMap.put("notebookcount", noteGateway.count(nb.getId()) + "篇笔记");
 				contentMap.put("id", nb.getId());
-			listItem.add(contentMap);}	}
-		else{
-			/**创建一个仅有提示意义的显示笔记本样本,没有实际的内容以及对象。*/
+				listItem.add(contentMap);
+			}
+		} else {
+			/** 创建一个仅有提示意义的显示笔记本样本,没有实际的内容以及对象。 */
 			HashMap<String, Object> noContentMap = new HashMap<String, Object>();
 			noContentMap.put("notebookname", "暂无笔记");
 			noContentMap.put("notebookcount", "没有笔记,没有书");
-			listItem.add(noContentMap);}	}	}
+			listItem.add(noContentMap);
+		}
+	}
+}

File Project/src/com/noodle/note/activity/NotebookManageCreatActivity.java

 public class NotebookManageCreatActivity extends Activity {
 	/** 新建笔记本之文件名 */
 	private EditText notebookName;
-	private Bundle bundle = this.getIntent().getExtras();
+	private Bundle bundle;
 	private NotebookGateway notebookGateway = (NotebookGateway) Session.getInstance(this).query(Notebook.class);
-	//TODO待修改
-	
+
+	// TODO待修改
 
 	protected void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.notebookmanage_creat);
-		
-		/** 两个底部Button的监听器设置*/
+		bundle = this.getIntent().getExtras();
+
+		/** 两个底部Button的监听器设置 */
 		Button buttonComplete = (Button) findViewById(R.id.noteBookButtonSubmit);
 		buttonComplete.setOnClickListener(submit);
 		Button buttonCancle = (Button) findViewById(R.id.noteBookButtonCancle);
 		buttonCancle.setOnClickListener(cancle);
-		
-		/**界面显示选择操作*/
-		WhichtoShow();}
-	
-	/** 新建笔记本与编辑笔记本共用一个界面,以下的显示操作以及按钮操作都是通过bundle内容来判断具体显示哪个界面内容以及进行什么操作*/
-	private void WhichtoShow(){
-		/**bundle为空,即重新建立一个新笔记本*/
+
+		/** 界面显示选择操作 */
+		WhichtoShow();
+	}
+
+	/**
+	 * 新建笔记本与编辑笔记本共用一个界面,以下的显示操作以及按钮操作都是通过bundle内容来判断具体显示哪个界面内容以及进行什么操作
+	 */
+	private void WhichtoShow() {
+		/** bundle为空,即重新建立一个新笔记本 */
 		if (null == bundle) {
 			TextView titleView = (TextView) findViewById(R.id.noteBookManageTitle);
 			titleView.setText("新建笔记本");
 			EditText hintView = (EditText) findViewById(R.id.noteBookNewName);
-			hintView.setHint("请输入笔记本名");}
-		/**bundle不为空,即笔记本原本存在,此时只是修改某些内容*/
+			hintView.setHint("请输入笔记本名");
+		}
+		/** bundle不为空,即笔记本原本存在,此时只是修改某些内容 */
 		else {
 			TextView titleView = (TextView) findViewById(R.id.noteBookManageTitle);
 			titleView.setText("编辑笔记本");
 			EditText hintView = (EditText) findViewById(R.id.noteBookNewName);
-			hintView.setText(bundle.getString("notebookName"));	}	}
-	
-	/** 按钮“完成“的操作设置 */
+			hintView.setText(bundle.getString("notebookName"));
+		}
+	}
+
+	/**
+	 * 按钮“完成“的操作设置
+	 */
 	OnClickListener submit = new OnClickListener() {
 		public void onClick(View v) {
-			/**bundle为空,做新建笔记本操作*/
+			// bundle为空,做新建笔记本操作
 			if (null == bundle) {
 				notebookName = (EditText) findViewById(R.id.noteBookNewName);
 				String content = notebookName.getText().toString();
 				Notebook notebook = new Notebook(content, "Zero");
 				notebookGateway.create(notebook);
 				Intent intent = new Intent();
-				intent.setClass(NotebookManageCreatActivity.this,
-						NotebookManageActivity.class);
-				startActivity(intent);}
-			/**bundle不为空,做修改笔记本操作*/
+				intent.setClass(NotebookManageCreatActivity.this, NotebookManageActivity.class);
+				startActivity(intent);
+				NotebookManageCreatActivity.this.finish();
+			}
+			// bundle不为空,做修改笔记本操作
 			else {
 				int listItemId = bundle.getInt("listItemId");
 				notebookName = (EditText) findViewById(R.id.noteBookNewName);
 				notebook.setName(content);
 				notebookGateway.update(notebook);
 				Intent intent = new Intent();
-				intent.setClass(NotebookManageCreatActivity.this,
-						NotebookManageActivity.class);
-				startActivity(intent);}	}	};
+				intent.setClass(NotebookManageCreatActivity.this, NotebookManageActivity.class);
+				startActivity(intent);
+				NotebookManageCreatActivity.this.finish();
+			}
+		}
+	};
 
-	/** 按钮“取消“的操作设置 */
+	/**
+	 * 按钮“取消“的操作设置
+	 */
 	OnClickListener cancle = new OnClickListener() {
 		public void onClick(View v) {
 			Intent intent = new Intent();
-			intent.setClass(NotebookManageCreatActivity.this,
-					NotebookManageActivity.class);
-			startActivity(intent);}	};	}
+			intent.setClass(NotebookManageCreatActivity.this, NotebookManageActivity.class);
+			startActivity(intent);
+			NotebookManageCreatActivity.this.finish();
+		}
+	};
+}

File Project/src/com/noodle/note/activity/NotesDisplayActivity.java

 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemClickListener;
 		initView();
 		setListener();
 	}
+
 	/**
 	 * 初始化视图
 	 */
 			listItem.add(noContentMap);
 		}
 	}
+
 	/**
 	 * 设置监听器
 	 */
 		listView.setAdapter(listSimpleAdapter);
 		listView.setOnItemClickListener(listItemListener);
 	}
+
 	/**
 	 * ListItem点击监听器
 	 */
 			startActivity(intent);
 		}
 	};
+
+	/**
+	 * 初始化Menu
+	 */
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		MenuInflater inflater = getMenuInflater();
+		inflater.inflate(R.menu.notes_menu, menu);
+		return true;
+	}
+
+	/**
+	 * Menu点击事件
+	 */
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item) {
+		switch (item.getItemId()) {
+		case R.id.notesTab1:{
+			startActivity(new Intent().setClass(this, EditNoteActivity.class));
+			return true;
+		}
+			
+		default:
+			return super.onOptionsItemSelected(item);
+		}
+	}
+
 }