在GridView单元格上绘制线-Android
到目前为止,这就是我的代码。为了在此时包含图像的单元格上画一条线,我想我知道我需要使用绘画或路径哪个?。在其中,我将声明起始点是什么,然后当用户触摸屏幕的另一部分时,这将是第二个点。欢迎提出任何建议。我真的,真的是新手,所以非常感谢您的帮助。谢谢。您可以重写onDraw方法以在视图中执行自定义绘图。有关详细信息,请参阅在GridView单元格上绘制线-Android,android,android-layout,Android,Android Layout,到目前为止,这就是我的代码。为了在此时包含图像的单元格上画一条线,我想我知道我需要使用绘画或路径哪个?。在其中,我将声明起始点是什么,然后当用户触摸屏幕的另一部分时,这将是第二个点。欢迎提出任何建议。我真的,真的是新手,所以非常感谢您的帮助。谢谢。您可以重写onDraw方法以在视图中执行自定义绘图。有关详细信息,请参阅 package com.hh.LetterGame; import android.app.Activity; import android.graphics.Canvas;
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;
}
}