ListView获取信息保存在本地数据库然后再显示信息。我想点击listview的items时删除它们,如何实现?
public class Notepad extends ListActivity { public static final int INSERT_ID = Menu.FIRST; EditText notes; Button add; ListView lv; String currentDateTimeString = DateFormat.getDateInstance().format( new Date()); private NotesDbAdapter mDbHelper; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.notepad_list); mDbHelper = new NotesDbAdapter(this); mDbHelper.open(); fillData(); Button add = (Button) findViewById(R.id.addNote); // ListView lv = (ListView) findViewById(R.id.list); add.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { createNote(); } }); // lv.setOnItemClickListener(new OnItemClickListener() { // // public void onItemClick(AdapterView<?> parent, View view, // int position, long id) { // // When clicked, show a toast with the TextView text // // try { // Toast.makeText(getApplicationContext(), // ((TextView) view).getText(), Toast.LENGTH_SHORT) // .show(); // // } catch (ClassCastException e) { // Toast.makeText(getApplicationContext(), "Error", // Toast.LENGTH_SHORT).show(); // } // // }; // // }); }
ListView:
<ListView android:id="@id/android:list" android:layout_width="wrap_content" android:layout_height="402dp" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_below="@+id/note" > </ListView>
牛魔王的故事
ITMISS
喵喔喔
相关分类