2013-08-24 34 views
0

我有落實onTouchListener,在這個類onDraw功能錯誤我把大寫字母和小寫字母的第一個函數名多斯特的不清晰,它顯示android中的onDraw函數錯誤?

刪除@override註釋

public class bsdselect extends Activity implements View.OnTouchListener { 
private ScaleGestureDetector mScaleDetector; 
final ArrayList<HashMap<String, String>> dataList = new ArrayList<HashMap<String, String>>(); 
private float mScaleFactor = 1.f; 
static String items; 
static String items1; 
static String dates; 
static String finalDate; 
int a,r,g,b; 
ListView lv; 
TextView text1;  
String COLOR; 
String GRPNAME; 
String QTY ; 
String BUDGET; 
String STOCK; 
String DIFF; 
String DIFF_P; 
TextView title; 
//protected Activity context; 

/* JSON Node names */ 
private static final String TAG_JSONDataResult = "JSONDataResult"; 
private static final String TAG_GRPNAME = "GRPNAME"; 
private static final String TAG_QNT = "QTY"; 
private static final String TAG_BUDGET = "BUDGET"; 
private static final String TAG_STOCK = "STOCK"; 
private static final String TAG_DIFF = "DIFF"; 
private static final String TAG_DIFF_P = "DIFF_P"; 
private static final String TAG_COLOR = "COLOR";  
// contacts JSONArray 
//JSONArray contacts = null; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.bsdselect); 
    //lv1=(ListView)findViewById(R.id.list1); 
    lv=(ListView)findViewById(R.id.listbsd); 
    title=(TextView)findViewById(R.id.title); 
    Bundle b=this.getIntent().getExtras(); 
    items=b.getString("item"); 
    items1=b.getString("item1"); 
    dates=b.getString("date"); 
    String topic=items+"/"+items1; 
    title.setText(topic); 

    SimpleDateFormat dateFormat = new SimpleDateFormat(
      "yyyy-MM-dd"); 
    Date myDate = null; 
    try { 
     myDate = dateFormat.parse(dates); 

    } catch (ParseException e) { 
     e.printStackTrace(); 
    } 

    SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd"); 
    finalDate = timeFormat.format(myDate); 
    torun(); 

} 

public void torun() { 
    String myUrl; 
    myUrl = String.format("http://192.168.2.16/RestServicebsd/RestServiceImpl.svc/jsons/?Location=%s&GROUP=%s&asondate=%s",items.replaceAll(" ","%20"),items1.replaceAll(" ","%20"),finalDate); 
    // String url0 = "http://192.168.2.16/RestServicebsd/RestServiceImpl.svc/jsons/?Location=Arihant Wanarpet&GROUP=ArihantShowroom&asondate=2013-2-24".replaceAll("","%20"); 

    // Hashmap for ListView 
    // final ArrayList<HashMap<String, String>> dataList = new ArrayList<HashMap<String, String>>(); 

    // Creating JSON Parser instance 
    JSONParser jParser = new JSONParser(); 
    // getting JSON string from URL 

    try { 

     JSONObject json1 = jParser.getJSONFromUrl(myUrl); 
     // Getting Array of Contacts 
     JSONArray list = json1.getJSONArray(TAG_JSONDataResult); 


     // looping through All Contacts 
     JSONObject c = null; 
     for(int i = 0; i < list.length(); i++){  
      c = list.getJSONObject(i); 

      // Storing each json item in variable 

      GRPNAME = c.getString(TAG_GRPNAME); 
      QTY = c.getString(TAG_QNT); 
      BUDGET = c.getString(TAG_BUDGET); 
      STOCK = c.getString(TAG_STOCK); 
      DIFF = c.getString(TAG_DIFF); 
      DIFF_P = c.getString(TAG_DIFF_P); 
      COLOR = c.getString(TAG_COLOR); 


      // creating new HashMap 
      HashMap<String, String> map = new HashMap<String, String>(); 

      // adding each child node to HashMap key => value 

      map.put(TAG_GRPNAME, GRPNAME); 
      map.put(TAG_QNT, QTY); 
      map.put(TAG_BUDGET, BUDGET); 
      map.put(TAG_STOCK, STOCK); 
      map.put(TAG_DIFF, DIFF); 
      map.put(TAG_DIFF_P, DIFF_P); 
      map.put(TAG_COLOR,COLOR); 



      // adding HashList to ArrayList 
      dataList.add(map); 
      c=null; 
     } 
    } catch (JSONException e) { 
     e.printStackTrace(); 
    } 
    /** 
    * Updating parsed JSON data into ListView 
    * */ 


} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    MenuInflater menuInflater = getMenuInflater(); 
    getMenuInflater().inflate(R.menu.main, menu); 
    return true; 
} 
@Override 
public boolean onOptionsItemSelected(MenuItem item) 
{ 

    switch (item.getItemId()) 
    { 
     case R.id.menu_Exit: 
      // Single menu item is selected do something 
      // Ex: launching new activity/screen or show alert message 
      //Toast.makeText(AndroidMenusActivity.this, "Bookmark is Selected", Toast.LENGTH_SHORT).show(); 
      finish(); 
      return true; 

     default: 
      return super.onOptionsItemSelected(item); 
    } 
} 
public void MyCustomView(Context mContext){ 
    //... 
    //Your view code 
    //... 
    onZoom(); 

    mScaleDetector = new ScaleGestureDetector(getBaseContext(), new ScaleListener()); 
} 

private void onZoom() { 
    // TODO Auto-generated method stub 
    ListAdapter adapter = new SimpleAdapter(this, dataList, 
      R.layout.list_item, 
      new String[] { TAG_GRPNAME, TAG_QNT, TAG_BUDGET, TAG_STOCK, TAG_DIFF, TAG_DIFF_P, }, 
      new int[] { 
        R.id.l2, R.id.l3, R.id.l4, R.id.l5, R.id.l6, R.id.l7}){ 
     @Override 
     public View getView(int position, View convertView, ViewGroup parent) { 
      View v = convertView; 
      if (v == null) { 
       LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
       v = vi.inflate(R.layout.list_item, null); 
      } 

        text1 = (TextView) v.findViewById(R.id.l7); 
        String rgbColor= dataList.get(position).get(TAG_COLOR); 
        String[] ARGB = rgbColor.split(" ");  
        a=Integer.parseInt(ARGB[0]); 
        r=Integer.parseInt(ARGB[1]); 
        g=Integer.parseInt(ARGB[2]); 
        b=Integer.parseInt(ARGB[3]);      
        text1.setBackgroundColor(Color.rgb(r, g, b)); 
        return super.getView(position, v, parent); 
      } 

    }; 


      lv.setAdapter(adapter); 

} 

@Override 
public boolean onTouch(View v, MotionEvent event) { 
    // TODO Auto-generated method stub 
    mScaleDetector.onTouchEvent(event); 
    v.invalidate(); 
    return super.onTouchEvent(event); 
} 
@Override 
public void onDraw(Canvas canvas) { 
super.onDraw(canvas); 

    canvas.save(); 
    canvas.scale(mScaleFactor, mScaleFactor); 
    //... 
    //Your onDraw() code 
    //... 
    lv.draw(canvas); 
    canvas.restore(); 
} 

private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { 
    @Override 
    public boolean onScale(ScaleGestureDetector detector) { 
     mScaleFactor *= detector.getScaleFactor(); 

     // Don't let the object get too small or too large. 
     mScaleFactor = Math.max(0.1f, Math.min(mScaleFactor, 5.0f)); 

     // v.invalidate(); 
     return true; 
    } 


    } 
} 
+0

因此,刪除註釋如果它這樣說.. – CRUSADER

+0

@CRUSADER刪除它後顯示方法onDraw(畫布)類型bsdselect必須覆蓋或實現超類型 – ibu

回答

0

如果它沒有顯示任何其他錯誤,只顯示刪除@override,然後刪除並嘗試運行它。

+0

如果我刪除它顯示錯誤方法onDraw(畫布)類型的bsdselect必須覆蓋或實現超類型 – ibu