1
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;
    }

}

到目前为止,这就是我的代码。为了在单元格(此时包含图像)上画一条线,我想我知道我需要使用 Paint 或 Path(哪一个?)。在其中,我将声明起点是什么,然后当用户触摸屏幕的另一部分时,这将是第二个点。欢迎任何建议。我对此非常非常陌生,因此非常感谢您提供任何帮助。谢谢你。

4

1 回答 1

0

您可以覆盖onDraw()在视图中执行自定义绘图的方法。在这里您可以找到更多信息的链接

于 2012-12-03T18:47:58.413 回答