关于ListView 显示的有关问题 !

关于ListView 显示的问题 在线等!!!!!
首先上我的代码:

 LinearLayout layout;
 layout=(LinearLayout)findViewById(R.id.llclass);
 layout.setOrientation(LinearLayout.HORIZONTAL);  
 
 LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);

  DatabaseHelper dbhelper=new DatabaseHelper(CheakOutActivity.this,"jxc");
  SQLiteDatabase db=dbhelper.getReadableDatabase();
  Cursor cursor=db.query("pcategory", null, null, null, null, null, null);
  if(cursor.getCount()>0)
  {
  Button Btn[] = new Button[cursor.getCount()];
  int i=0;
  while(cursor.moveToNext())
  {
  final String pid=cursor.getString(cursor.getColumnIndex("_id")); 
  String classname=cursor.getString(cursor.getColumnIndex("category")); 
  Btn[i]=new Button(this);
  Btn[i].setId(2000+i); 
      Btn[i].setText(classname);
      
      Btn[i].setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
lvgoods=(ListView) findViewById(R.id.GoodsListView);  
DatabaseHelper dbhelper1=new DatabaseHelper(CheakOutActivity.this,"jxc");
SQLiteDatabase db1=dbhelper1.getReadableDatabase();
Cursor cursor1=db1.query("category", null, "pid='"+pid+"'", null, null, null, null);
 SimpleCursorAdapter adapter = new SimpleCursorAdapter(CheakOutActivity.this, R.layout.my_listitemcoclass, cursor1,new String[]{"category","fenliang","price"}, new int[]{R.id.Goodsname,R.id.Goodsfl,R.id.Goodsprice});  
                 lvgoods.setAdapter(adapter);  
                 Toast.makeText(CheakOutActivity.this, "父类ID:"+pid+"--"+cursor1.getCount(), 500).show(); 
              db1.close();
                
                 
              lvgoods.setOnItemClickListener(new ItemClickListener());  
              
              
}
      
      });
      
      
      layout.addView(Btn[i],lp);


Button 都可以正常显示  点击button 的时候Toast.makeText(CheakOutActivity.this, "父类ID:"+pid+"--"+cursor1.getCount(), 500).show();   这一行也可以打印出来  而且cursor1.getCount()是大于0的  代表有查询到数据  但listview lvgoods 里面没有显示任何数据  也没有报错  郁闷 不知道从那有问题 请大侠们指教  一下 谢谢!

文章评论