나는 안드로이드 및 자바 개발에 매우 익숙하다. 나는 아주 기본적인 4x4 스도쿠 응용 프로그램을 만들려고 노력하고있다. 그러나 코드를 실행할 때 UI가 충돌합니다. 코드의 어느 부분이 정확하지 않은지 잘 모르겠습니다.스도쿠 솔루션 체크인 안드로이드
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.level1);
findviewbyidfunc();
checksol.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
setmatrix();
ans=check(mat);
dispsol();
}
});
}
public void findviewbyidfunc()
{
checksol=(Button)findViewById(R.id.checksol1);
r11=(EditText)findViewById(R.id.r1c1);
r21=(EditText)findViewById(R.id.r2c1);
r31=(EditText)findViewById(R.id.r3c1);
r41=(EditText)findViewById(R.id.r4c1);
r12=(EditText)findViewById(R.id.r1c2);
r22=(EditText)findViewById(R.id.r2c2);
r32=(EditText)findViewById(R.id.r3c2);
r42=(EditText)findViewById(R.id.r4c2);
r13=(EditText)findViewById(R.id.r1c3);
r23=(EditText)findViewById(R.id.r2c3);
r33=(EditText)findViewById(R.id.r3c3);
r43=(EditText)findViewById(R.id.r4c3);
r14=(EditText)findViewById(R.id.r1c4);
r24=(EditText)findViewById(R.id.r2c4);
r34=(EditText)findViewById(R.id.r3c4);
r44=(EditText)findViewById(R.id.r4c4);
displayanswer=(EditText)findViewById(R.id.answer);
}
매트릭스를 설정하는 코드.
public void setmatrix()
{
//Column one
mat[1][1]=Integer.parseInt(r11.getText().toString());
mat[2][1]=Integer.parseInt(r21.getText().toString());
mat[3][1]=Integer.parseInt(r31.getText().toString());
mat[4][1]=Integer.parseInt(r41.getText().toString());
//Column two
mat[1][2]=Integer.parseInt(r12.getText().toString());
mat[2][2]=Integer.parseInt(r22.getText().toString());
mat[3][2]=Integer.parseInt(r32.getText().toString());
mat[4][2]=Integer.parseInt(r42.getText().toString());
//Column three
mat[1][3]=Integer.parseInt(r13.getText().toString());
mat[2][3]=Integer.parseInt(r23.getText().toString());
mat[3][3]=Integer.parseInt(r33.getText().toString());
mat[4][3]=Integer.parseInt(r43.getText().toString());
//Column four
mat[1][4]=Integer.parseInt(r14.getText().toString());
mat[2][4]=Integer.parseInt(r24.getText().toString());
mat[3][4]=Integer.parseInt(r34.getText().toString());
mat[4][4]=Integer.parseInt(r44.getText().toString());
}
코드 행렬을 확인합니다. 나는 청취자 코드 및 관련 기능을 제거하면
public boolean check(Integer arr[][])
{
Integer[] count={0,0,0,0,0};
Integer[] count1={0,0,0,0,0};
Boolean b=true;
for(int i=1;i<4;i++)
{
for(int j=1;j<4;j++)
{
if(count[arr[j][i]]>i)
{
b=false;
return b;
}
if(count1[arr[i][j]]>i)
{
b=false;
return b;
}
count1[arr[i][j]]++;
count[arr[j][i]]++;
}
}
return b;
}
는, 인터페이스는 잘 작동합니다. 무엇이 잘못되었는지 확신하지 못합니다. 당신의 글고 위젯의
로그 캣 당신을 알려줍니다. logCat 오류를 게시하십시오. – Razgriz
게시물을 편집하여 여기에 게시하십시오. 여기에는 게시되지 않습니다. – Razgriz
Thanks ... LogCat 오류를 게시했습니다 .. – user2899503