public void RestartGame(){
//清除数据
mWhiteArray.clear();
mBlackArray.clear();
mIsGameOver = false;
mIsWhiteWinner = false;
invalidate();
}
public class MainActivity extends AppCompatActivity {
private wuziqiPanel wuziqiPanel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wuziqiPanel=(wuziqiPanel) findViewById(R.id.id_wuziqi);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main,menu);
return true;
}
@Override
public boolean onContextItemSelected(MenuItem item) {
int id=item.getItemId();
if(id==R.id.action_settings) {
wuziqiPanel.start();
return true;
}
return super.onContextItemSelected(item);
}
}
<com.msz_wuziqi.wuziqiPanel
android:id="@+id/id.wuziqi"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>