2014-07-09 82 views
0

我正在製作一個繪畫應用程序,以瞭解如何使用eclipse。path.reset與菜單項onclick

只要點擊菜單項「重置」,我想清除我的(繪畫)視圖 菜單項「重置」在XML文件中。現在我知道我必須使用path.reset,但不知道在哪裏寫它。希望有人能幫助我。

<item android:id="@+id/ResetAction" 
     android:orderInCategory="100" 
     android:title="Reset" 
     android:showAsAction="never" 
     android:menuCategory="container" 
     ></item> 

一個

public class SingleTouchActivity extends Activity 

{ 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(new SingleTouchEventView(this, null)); 
     } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 

     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 

    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     // Handle action bar item clicks here. The action bar will 
     // automatically handle clicks on the Home/Up button, so long 
     // as you specify a parent activity in AndroidManifest.xml. 
     int id = item.getItemId(); 
     if (id == R.id.action_settings) { 
      return true; 
     } 
     return super.onOptionsItemSelected(item); 
    } 

    /** 
    * A placeholder fragment containing a simple view. 
    */ 
    public static class PlaceholderFragment extends Fragment { 

     public PlaceholderFragment() { 
     } 

     @Override 
     public View onCreateView(LayoutInflater inflater, ViewGroup container, 
       Bundle savedInstanceState) { 
      View rootView = inflater.inflate(R.layout.main_fragment, container, 
        false); 
      return rootView; 
     } 
    } 

} 

回答

0

Path.reset()是用於重新使用Path對象的方法。例如,如果使用Path對象繪製在每個幀處(在繪製(Canvas)或onDraw(Canvas)方法)的幀開始處更改的形狀,則可以重置重置路徑,將新形狀添加到路徑,然後繪製路徑(canvas.drawPath())