public class MainActivity extends ActionBarActivity implements OnClickListener{
//private NotesDB notesDB;
//private SQLiteDatabase dbWriter;
private Button textbtn,imgbtn,videobtn;
private ListView lv;
private Intent i;
private MyAdapter adapter;
private NotesDB notesDB;
private SQLiteDatabase dbReader;
public Cursor cursor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
/*notesDB = new NotesDB(this);
dbWriter = notesDB.getWritableDatabase();
//addDB();*/
}
public void initView(){
lv = (ListView) findViewById(R.id.list);
textbtn = (Button) findViewById(R.id.text);
imgbtn = (Button) findViewById(R.id.img);
videobtn = (Button) findViewById(R.id.video);
textbtn.setOnClickListener(this);
imgbtn.setOnClickListener(this);
videobtn.setOnClickListener(this);
notesDB = new NotesDB(this);
dbReader = notesDB.getReadableDatabase();
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
cursor.moveToPosition(position);
Intent i = new Intent(MainActivity.this,SelectAct.class);
i.putExtra(NotesDB.ID, cursor.getInt(cursor.getColumnIndex(NotesDB.ID)));
i.putExtra(NotesDB.CONTENT, cursor.getString(cursor.getColumnIndex(NotesDB.CONTENT)));
i.putExtra(NotesDB.TIME, cursor.getString(cursor.getColumnIndex(NotesDB.TIME)));
i.putExtra(NotesDB.PATH, cursor.getString(cursor.getColumnIndex(NotesDB.PATH)));
i.putExtra(NotesDB.VIDEO,cursor.getString(cursor.getColumnIndex(NotesDB.VIDEO)));
startActivity(i);
}
});
}