Lv=(ListView) the findViewById (R.i d.l v);
Lists=new ArrayList(a);
Adapter=new MyAdapter ();
Lv. SetAdapter (adapter);
ListLists=new ArrayList (a);
Myhelper Myhelper=new Myhelper (memolist. This);
SQLiteDatabase db=myhelper. GetReadableDatabase ();
Cursor Cursor=db. Query (" memolist ", null, null, null, null, null, null);
If (cursor!=null& & Cursor. GetCount () & gt; 0 {
While (cursor. MoveToNext ()) {
String number=cursor. Get String (cursor. GetColumnIndex (" number "));
The String content=cursor. Get String (cursor. GetColumnIndex (" memoname "));
MemoData memodata=https://bbs.csdn.net/topics/new MemoData (content, number);
Memodata. SetNumber (number);
Memodata. SetContent (content);
Lists. The add (memodata);
}
Cursor. The close ();
The close ();
Adapter. NotifyDataSetChanged ();
}
}
//adapter
Private class MyAdapter extends BaseAdapter {
@ Override
Public int getCount () {
//TODO Auto - generated method stub
Return lists. The size ();
}
@ Override
Public Object the getItem (int arg0) {
//TODO Auto - generated method stub
return null;
}
@ Override
Public long getItemId (int arg0) {
//TODO Auto - generated method stub
return 0;
}
@ Override
Public View getView (int position, View converView, ViewGroup parent) {
//TODO Auto - generated method stub
View the View;
//if (converView==null) {
View=the inflate (getApplicationContext (), R.l ayout. Item,
Null);
//} else {
//the view=converView;
//}
TextView user_number=(TextView) view. The findViewById (R.i d.n o);
TextView user_memoname=(TextView) view. The findViewById (R.i d.n ame);
TextView time=(TextView) view. The findViewById (R.i which ime);
MemoData MemoData=https://bbs.csdn.net/topics/lists.get (position);
User_number. SetText (memodata getNumber ());
User_memoname. SetText (memodata getContent ());
//time. The setText (memodata getTime ());
Return the view;
}
Public class MemoData {
private String content;
Private String number;
Private String time;
Public String getContent () {
return content;
}
Public void setContent (String content) {
this.content=content;
}
Public String getNumber () {
Return the number;
}
Public void setNumber (String number) {
This. Number=number;
}
Public String getTime () {
The return time.
}
Public void setTime (String time) {
This. Time=the time;
}
Public MemoData (String content, String number, String time) {
super();
this.content=content;
This. Number=number;
This. Time=the time;
}
Public MemoData (String content, String number) {
super();
this.content=content;
This. Number=number;
}
}
CodePudding user response:
Also post the error log, look at is where the null pointerCodePudding user response:
Posted look at the wrong placeCodePudding user response:
GetItemId, and the getItem return you didn't changeCodePudding user response:
View the View;
//if (converView==null) {
View=the inflate (getApplicationContext (), R.l ayout. Item,
Null);
//} else {
//the view=converView;
//}
He did have a good look at the wrong
CodePudding user response:
Agree with upstairs, is it mistakeCodePudding user response:
@ OverridePublic Object the getItem (int arg0) {
//TODO Auto - generated method stub
return null;
}
@ Override
Public long getItemId (int arg0) {
//TODO Auto - generated method stub
return 0;
}
The return value here are no change
CodePudding user response:
How to still use the list view