그래서 저는 어떤 종류의 자바에서 멍청한 놈으로 안드로이드 용 앱을 만들려고합니다. 일부 오류가 발생했지만 해결할 수 없습니다. 누가 그 문제가 무엇인지 찾는 것을 도울 수 있습니까?android 용 java 앱의 오류
package com.example.w;
//import com.example.jkhgvcxz.R;
import views.DrawView;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;
public class MainActivity extends Activity {
Ponto2D patual = new Ponto2D();
int contador = 0;
DrawView drawView;
View view2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RelativeLayout rl = (RelativeLayout) findViewById(R.id.rl);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(500, 500);
params.leftMargin = 50;
params.topMargin = 50;
drawView = new DrawView(this);
drawView.setBackgroundColor(Color.WHITE);
rl.addView(drawView, params);
drawView.setOnTouchListener(new View.OnTouchListener() {
// @Override
public boolean onTouch(View v, MotionEvent event) {
Ponto2D patual = new Ponto2D((int)event.getX(), (int)event.getY()); Reta r1 = new Reta (inicio, fim);
DrawView.ar[contador] =rl[];
inicio.X = \.X;
inicio.Y = fim.Y;
contador++;
if (event.getAction()== MotionEvent.ACTION_DOWN)
{
drawView.a=7;
drawView.antigox=drawView.X;
drawView.antigoy=drawView.Y;
drawView.X=event.getX();
drawView.Y=event.getY();
//drawView.draw();
drawView.desenhar_quadrado();}
return true;
}
});
}
public void btn(View v)
{
drawView.desenhar_quadrado();
}
public void btn_verde(View v)
{
drawView.paint.setColor(Color.GREEN);
}
public void btn_vermelho(View v)
{
drawView.paint.setColor(Color.RED);
}
public void btn_preto(View v)
{
drawView.paint.setColor(Color.BLACK);
}
public void btn_azul(View v)
{
drawView.paint.setColor(Color.BLUE);
}
public void btn_amarelo(View v)
{
drawView.paint.setColor(Color.YELLOW);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
내 RETA 클래스 :
package com.example.w;
public class Reta {
Ponto2D inicio;
Ponto2D fim;
int cor;
public Reta(Ponto2D p1, Ponto2D p2){
inicio = new Ponto2D(p1.x, p1.y);
fim = new Ponto2D(p2.x, p2.y);
}
}
내 DrawView 클래스 :
package views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
import com.example.w.Reta;
public class DrawView extends View {
public Paint paint = new Paint();
Reta ar[] = new Reta [10];
public int a;
public float antigox=0;
public float antigoy=0;
public float X=0;
public float Y=0;
public DrawView(Context context) {
super(context);
paint.setColor(Color.BLACK);
a=0;
}
public void desenhar_quadrado()
{
invalidate();
}
@Override
public void onDraw(Canvas canvas) {
for(int j=0; j<10; j++){
drawLine(ar[j].inicio.x, ar[j].inicio.y);
}
}
}
그리고 내 Ponto2D 클래스 :
package com.example.w;
public class Ponto2D {
int x;
int y;
public Ponto2D()
{
x = -1;
y = -1;
}
public Ponto2D(int x, int y)
{
this();
this.x = x;
this.y = y;
}
}
다음
내 mainActivity입니다 0
지금은 내가 얻을 라인 34 (44-50)
DrawView.java에서 또한- The constructor Ponto2D(float, float) is undefined
- fim cannot be resolved to a variable
- inicio cannot be resolved to a variable
- line 47: Syntax error on token "[", Expression expected after this token
- Cannot refer to a non-final variable rl inside an inner class defined in a different method
- The field DrawView.ar is not visible
- The type of the expression must be an array type but it resolved to RelativeLayout
- fim cannot be resolved to a variable - inicio cannot be resolved to a variable.
가지고 : 당신이 정의 결코이
public class MainActivity extends Activity {
Ponto2D patual = new Ponto2D(); <---- here
//...
}
에서
- The field Reta.inicio is not visible,
- The method drawLine(int, int) is undefined for the type DrawView
- The field Reta.inicio is not visible
- The field Ponto2D.x is not visible.
당신은 당신이 무엇을 얻을 오류 설명 경우 도움이 될 ... – assylias
행 18 : 생성자 Ponto2D는() undefined- 와치 포인트입니다 : MainActivity [액세스 및 수정] \t - patual –
가 이해가 안 스페인어를 배우지 만, 어떤 이유로 든 Rect와 Point2D 클래스를 재발 명하고 있습니다. 그래서 문제를 일으키는 클래스 중 하나라고 생각합니다. 예를 들어 코드에 사용중인 Ponto2D() 생성자가 표시되지 않습니다. – Shark