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

}

これがこれまでの私のコードです。セル (現時点では画像が含まれています) の上に線を引くには、ペイントまたはパス (どちらですか?) を使用する必要があることはわかっていると思います。その中で、開始点が何であるかを宣言し、ユーザーが画面の別の部分に触れると、それが 2 番目の点になります。どんな提案も歓迎します。私はこれに本当に本当に慣れていないので、どんな助けも大歓迎です。ありがとうございました。

4

1 に答える 1

0

メソッドをオーバーライドonDraw()して、ビューでカスタム描画を実行できます。詳細については、リンクを参照してください。

于 2012-12-03T18:47:58.413 に答える