日期:2014-05-16 浏览次数:20612 次
package com.b509.activity.patient; import java.util.ArrayList; import java.util.List; import com.b509.tools.CornerListView; import com.b509.R; import com.b509.activity.patient.mydoctors.service.OtherPersonService; import com.b509.activity.patient.mydoctors.service.Person; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.Gravity; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.LinearLayout; import android.widget.TextView; public class IllnessNoteActivity extends Activity { CornerListView note; List<Person> persons; List<String> illness_list; List<String> illness_time; List<Integer> illness_id; private OnItemClickListener itemClickListener; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.illnessnote); illness_list = new ArrayList<String>(); illness_time = new ArrayList<String>(); illness_id = new ArrayList<Integer>(); note = (CornerListView) findViewById(R.id.lv_note); persons = updatalist(); System.out.println(persons.size() + "??????????????????????"); for (int i = 0; i < persons.size(); i++) { String time = persons.get(i).getTime(); System.out.println(time); String illness = persons.get(i).getIllness(); System.out.println(illness); Integer id = persons.get(i).getId(); System.out.println(id); illness_list.add(illness); illness_time.add(time); illness_id.add(id); } initListView(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // TODO Auto-generated method stub menu.add(0, 1, 1, "新建记录"); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { // TODO Auto-generated method stub Intent intent = new Intent(); Bundle bubdle = new Bundle(); bubdle.putInt("flag", 1); intent.putExtras(bubdle); intent.setClass(IllnessNoteActivity.this, EditNoteActivity.class); startActivity(intent); return super.onOptionsItemSelected(item); } private void initListView() { itemClickListener = new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { System.out.println("-----------------------"); final int a = arg2; AlertDialog.Builder builder = new AlertDialog.Builder( IllnessNoteActivity.this); builder.setTitle("选项"); final String[] messages = { "查看", "删除", }; builder.setItems(messages, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub switch (which) { case 0: Intent intent = new Intent(); int item_all = illness_list.size(); Bundle bubdle = new Bundle(); bubdle.putInt("all_nub", item_all); bubdle.putInt("item_", a); bubdle.putInt("flag", 2); intent.putExtras(bubdle); intent.setClass(IllnessNoteActivity.this, EditNoteActivity.class); startActivity(intent); break; case 1: int item_all2 = illness_list.size(); int id = item_all2 - a; OtherPersonService personService = new OtherPersonService( IllnessNoteActivity.this); personService.delete(id); illness_list.remove(a); illness_time.remove(