各位大虾帮帮忙啊!!什么错误也没有,程序正常运行,在控制台查看那个数据时候看到有数据!!//这里是Listview绑定Adapter
Cursor cursor2 = myDataBaseAdapter.fecthInjectionQuarantine();
startManagingCursor(cursor2);
System.out.println("cursor2"+cursor2.getCount());
if (cursor2 != null && cursor2.getCount()>0) {
Adapter adapter = new Adapter(ShowBadyInformation.this,
R.layout.show_injectioned_quarantine,
cursor2,
new String[]{"_id", MyDataBaseAdapter.QUARANTINE_TYPE},
new int[]{R.id.text1, R.id.text1}
);
injectionedQuarantineListView.setAdapter(adapter);
}
cursor2.close();
下面是重写的//重写SimpleCursorAdapter
public class Adapter extends SimpleCursorAdapter{ private LayoutInflater mInflater;
public Adapter(Context context, int layout, Cursor c, String[] from,
int[] to) {
super(context, layout, c, from, to);
// TODO Auto-generated constructor stub
System.out.println("123");
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
// TODO Auto-generated method stub
super.bindView(view, context, cursor);
//得到每一个view的布局文件
LinearLayout ll = null;
if(view == null){
ll = (LinearLayout) mInflater.inflate(R.layout.show_injectioned_quarantine, null);
}else{
ll = (LinearLayout) view;
}
TextView textView = (TextView) ll.findViewById(R.id.text1);
int name = cursor.getColumnIndex("_id");
int type = cursor.getColumnIndex(MyDataBaseAdapter.QUARANTINE_TYPE);
String nameString = cursor.getString(name);
String typeString = cursor.getString(type);
System.out.println("nameString+typeString"+nameString+typeString);
if (typeString.length()==1) {
textView.setText(nameString);
}else {
textView.setText(nameString + typeString);
}
}
}
Cursor cursor2 = myDataBaseAdapter.fecthInjectionQuarantine();
startManagingCursor(cursor2);
System.out.println("cursor2"+cursor2.getCount());
if (cursor2 != null && cursor2.getCount()>0) {
Adapter adapter = new Adapter(ShowBadyInformation.this,
R.layout.show_injectioned_quarantine,
cursor2,
new String[]{"_id", MyDataBaseAdapter.QUARANTINE_TYPE},
new int[]{R.id.text1, R.id.text1}
);
injectionedQuarantineListView.setAdapter(adapter);
}
cursor2.close();
下面是重写的//重写SimpleCursorAdapter
public class Adapter extends SimpleCursorAdapter{ private LayoutInflater mInflater;
public Adapter(Context context, int layout, Cursor c, String[] from,
int[] to) {
super(context, layout, c, from, to);
// TODO Auto-generated constructor stub
System.out.println("123");
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
// TODO Auto-generated method stub
super.bindView(view, context, cursor);
//得到每一个view的布局文件
LinearLayout ll = null;
if(view == null){
ll = (LinearLayout) mInflater.inflate(R.layout.show_injectioned_quarantine, null);
}else{
ll = (LinearLayout) view;
}
TextView textView = (TextView) ll.findViewById(R.id.text1);
int name = cursor.getColumnIndex("_id");
int type = cursor.getColumnIndex(MyDataBaseAdapter.QUARANTINE_TYPE);
String nameString = cursor.getString(name);
String typeString = cursor.getString(type);
System.out.println("nameString+typeString"+nameString+typeString);
if (typeString.length()==1) {
textView.setText(nameString);
}else {
textView.setText(nameString + typeString);
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货