package com.hh.LetterGame;
import android.app.Activity;
import android.graphics.Canvas;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.Toast;
public class MainActivity extends Activity {
//This is what is first displayed when the person opens the app:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Displays the letters on the board.
GridView gridview = (GridView) findViewById(R.id.letters);
gridview.setAdapter(new letterImageAdapter(this));
//Controls what is displayed when the user clicks on the letter.
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(MainActivity.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
//Displays the header, including players and word selected.
//NOT FINISHED: Needs to show player pictures and also the word the player is making.
GridView header = (GridView) findViewById(R.id.header);
}
//Draw lines between the letters.
//Menu options within the app.
@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;
}
}
这就是我到目前为止的代码。为了在单元格(此时包含图像)上画一条线,我想我知道我需要使用油漆或路径(哪一个?在其中,我将声明起点是什么,然后当用户触摸屏幕的另一部分时,这将是第二个点。欢迎任何建议。我真的非常非常陌生,所以非常感谢任何帮助。谢谢。
您可以重写onDraw()
方法以在视图中执行自定义绘图。在这里,您可以找到链接以获取更多信息。