2014-08-27 72 views
0

当我试图在列表视图中实现显示数组值和图像时,它显示了红线错误删除覆盖令牌的oncreate和在listview公共标识符也显示红线错误。Android onCreate - 令牌“覆盖”的语法错误,删除此令牌

这里是我的代码:

import android.app.Activity; 
import android.content.Context; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.BaseAdapter; 
import android.widget.ImageView; 
import android.widget.ListView; 
import android.widget.TextView; 

public class ScanNow extends Activity{ 
    ListView listView; 
    public Integer[] imgid = {R.drawable.image1,R.drawable.image2,R.drawable.image3,R.drawable.image4, 
      R.drawable.image6,R.drawable.image7,R.drawable.image8,R.drawable.image9, 
      R.drawable.image10,R.drawable.image11,R.drawable.image12,R.drawable.image13}; 
    SampleAdapter sAdapter; 
    public String[] imageNames ={"Deli Purchase of $5 or more","20-oz. or Large Market Pantry frozen chicken item","64-oz. Market Pantry juice or juice cocktails","With Purchase of any two Betty Crocker items","4.2-lb. or larger Kingsford charcoal","Engergizer batteries","$10 or higher Energizer flashlight","With purchase of any two axe items","Fresh fruit purchase of $5 or more","Fresh meat purchase of $5 orr more","Fresh vegetable purchase of $5 or more","With purchase of two 5-oz. or larger Market Pantry cheeses"}; 
    public String[] imagePrice ={"$2 off","$1 off","$1 off","75ç off","1$ off","1$ off","2$ off","1$ off","$1 off","$1 off","$1 off","$1 off"}; 


    Context ct; 
    Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.scannow); 
     ct=this; 
     listView=(ListView)findViewById(R.id.listView1); 
     sAdapter=new SampleAdapter(ct); 
     listView.setAdapter(sAdapter); 

    } 
    class SampleAdapter extends BaseAdapter{ 
    LayoutInflater li; 
    Context c; 
    ImageView img; 
    TextView price,desc; 
    Override 
    public SampleAdapter(Context ct1) { 
     c=ct1; 
    } 

    public int getCount() { 
     // TODO Auto-generated method stub 
     return imgid.length; 
    } 

    Override 
    public Object getItem(int arg0) { 
     // TODO Auto-generated method stub 
     return arg0; 
    } 

    Override 
    public long getItemId(int arg0) { 
     // TODO Auto-generated method stub 
     return arg0; 
    } 

    Override 
    public View getView(int arg0, View arg1, ViewGroup arg2) { 
     li=(LayoutInflater)c.getSystemService(LAYOUT_INFLATER_SERVICE); 
     arg1=li.inflate(R.layout.barcode_products_freeitemcell, null); 
     img=(ImageView)arg1.findViewById(R.id.priceimage); 
     price=(TextView)arg1.findViewById(R.id.priceoff); 
     desc=(TextView)arg1.findViewById(R.id.pricedesc); 
     img.setImageResource(imgid[arg0]); 
     price.setText(imagePrice[arg0]); 
     desc.setText(imageNames[arg0]); 
     return arg1; 
    } 

    } 
} 

回答

1

你应该写,而不是@overrideoverride

相关问题