package com.mycross_ap3;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
public class Level1 extends Activity {
TextDialog dialog;
int hintcount = 0;
int char3 = 2;
int char4 = 3;
String Level1_HINT[] = { "HINT1", "HINT2", "HINT3", "HINT4" };
TextView[][] answerlist;
void charselecter(int select,int charr, int width, int height,boolean WH){
final int selectNUM = select;
final int Width = width; final int Height = height;
int charNUM = charr;
if(WH==true){ //가로일때
for (int i = 0; i <= charNUM; i++) {
answerlist[Height][Width+i].setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
TextDialog.temp = selectNUM;
dialog.show();
}
});
}
}else{
for (int i = 0; i <= charNUM; i++) {
answerlist[height+i][Width].setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
TextDialog.temp = selectNUM;
dialog.show();
}
});
}
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_level1);
TextView[][] answerlist = { // 퍼즐
// 1line
{(TextView) findViewById(R.id.xy00),// first [0]
(TextView) findViewById(R.id.xy10),
(TextView) findViewById(R.id.xy20),
(TextView) findViewById(R.id.xy30),
(TextView) findViewById(R.id.xy40)},
// 2line
{(TextView) findViewById(R.id.xy01),
(TextView) findViewById(R.id.xy11),
(TextView) findViewById(R.id.xy21),
(TextView) findViewById(R.id.xy31),
(TextView) findViewById(R.id.xy41)},
// 3line
{(TextView) findViewById(R.id.xy02),
(TextView) findViewById(R.id.xy12),
(TextView) findViewById(R.id.xy22), // center [12]
(TextView) findViewById(R.id.xy32),
(TextView) findViewById(R.id.xy42)},
// 4line
{(TextView) findViewById(R.id.xy03),
(TextView) findViewById(R.id.xy13),
(TextView) findViewById(R.id.xy23),
(TextView) findViewById(R.id.xy33),
(TextView) findViewById(R.id.xy43)},
// 5line
{(TextView) findViewById(R.id.xy04),
(TextView) findViewById(R.id.xy14),
(TextView) findViewById(R.id.xy24),
(TextView) findViewById(R.id.xy34),
(TextView) findViewById(R.id.xy44), }}; // last [24]
// 힌트
final TextView HINTVIEW = (TextView) findViewById(R.id.HINTTEXT);
// 다이얼로그생성
dialog = new TextDialog(Level1.this);
// dialog.setTitle("dialog");
switch (TextDialog.level_NUM) {
case 0:
// 공백부분제거
answerlist[0][4].setVisibility(View.INVISIBLE);
answerlist[1][1].setVisibility(View.INVISIBLE);
answerlist[1][2].setVisibility(View.INVISIBLE);
answerlist[1][3].setVisibility(View.INVISIBLE);
answerlist[2][3].setVisibility(View.INVISIBLE);
answerlist[3][0].setVisibility(View.INVISIBLE);
answerlist[3][2].setVisibility(View.INVISIBLE);
answerlist[3][3].setVisibility(View.INVISIBLE);
answerlist[4][0].setVisibility(View.INVISIBLE);
HINTVIEW.setText(Level1_HINT[0]);
// 버튼생성
charselecter(0,3,0,0,true);
// 레벨별 디스미스리스너
dialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (TextDialog.msg.equals(TextDialog.answertemp[TextDialog.temp])) {
// 가로지문
}
}
});
break;
case 1:
break;
case 2:
break;
}
}
/*
* final AlertDialog.Builder builder = new AlertDialog.Builder(this);
* LayoutInflater inflater = this.getLayoutInflater();
* builder.setView(inflater.inflate(R.layout.activity_dialog, null));
* builder.setCancelable(true);
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.level1, menu);
return true;
}
}