import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TabHost;
import android.widget.Toast;
import com.example.smartnameplate.R;
public class TabLayoutActivity extends TabActivity {
EditText LOGid = null;
EditText LOGpw = null;
ArrayList<String> arr = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.testmain);
EditText loginpw = (EditText) findViewById(R.id.loginpw);
EditText idtestplz = (EditText) findViewById(R.id.idtestplz);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, TabActivity1.class);
spec = tabHost.newTabSpec("Tab1");
spec.setIndicator("Main",
res.getDrawable(android.R.drawable.ic_menu_agenda));
spec.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, TabActivity2.class);
spec = tabHost.newTabSpec("Tab2");
spec.setIndicator("Preview",
res.getDrawable(android.R.drawable.ic_menu_edit));
spec.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, TabActivity3.class);
spec = tabHost.newTabSpec("Tab3");
spec.setIndicator("Update",
res.getDrawable(android.R.drawable.ic_menu_help));
spec.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, TabActivity4.class);
spec = tabHost.newTabSpec("Tab4");
spec.setIndicator("Download",
res.getDrawable(android.R.drawable.ic_menu_day));
spec.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, TabActivity5.class);
spec = tabHost.newTabSpec("Tab5");
spec.setIndicator("Upload",
res.getDrawable(android.R.drawable.ic_menu_help));
spec.setContent(intent);
tabHost.addTab(spec);
Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog,
(ViewGroup) findViewById(R.id.layout_root));
AlertDialog.Builder aDialog = new AlertDialog.Builder(
TabLayoutActivity.this);
aDialog.setTitle("로그인하시겠습니까?");
aDialog.setView(layout);
aDialog.setPositiveButton("로그인", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
readText();
EditText LOGid = (EditText) findViewById(R.id.loginid);
for (int i = 0; i < 5; i++) {
Log.d("for",
"******************for성공*****************");
if (arr.get(i).toString().equalsIgnoreCase(LOGid.getText().toString())) {
//if(arr.get(i).toString() == LOGid.getText().toString()){
Log.d("if", "****************if성공**************");
Toast.makeText(TabLayoutActivity.this, "로그인 되었습니다.",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(TabLayoutActivity.this, "로그인 실패하였습니다.",
Toast.LENGTH_SHORT).show();
}
}
}
});
aDialog.setNegativeButton("취소", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(TabLayoutActivity.this, "어플이 종료됩니다.",
Toast.LENGTH_SHORT).show();
finish();
}
});
AlertDialog ad = aDialog.create();
ad.show();
}
public void readText() {
try {
Log.i("124312", "sfsdfsfasfscfsd cfsearbsd");
Resources resources = getResources();
BufferedReader br = new BufferedReader(new InputStreamReader(
resources.openRawResource(R.raw.mytest2), "UTF-8"));
String readLine;
while ((readLine = br.readLine()) != null) {
arr.add(readLine + "\n");
}
br.close();
// EditText edtFile = (EditText) findViewById(R.id.edtFile);
// edtFile.setText(arr.get(0));
} catch (Exception e) {
Toast.makeText(this, "읽기 오류 : " + e, 4000).show();
}
}
}
mytest2
abc
def
ghi
mno
pqr
로그
05-22 03:13:52.371: E/Trace(2124): error opening trace file: No such file or directory (2)
05-22 03:13:52.971: D/dalvikvm(2124): GC_FOR_ALLOC freed 56K, 4% free 8285K/8583K, paused 190ms, total 191ms
05-22 03:13:52.982: I/dalvikvm-heap(2124): Grow heap (frag case) to 8.758MB for 649280-byte allocation
05-22 03:13:53.091: D/dalvikvm(2124): GC_CONCURRENT freed <1K, 4% free 8919K/9223K, paused 72ms+9ms, total 107ms
05-22 03:13:53.562: I/Choreographer(2124): Skipped 80 frames! The application may be doing too much work on its main thread.
05-22 03:13:53.572: D/gralloc_goldfish(2124): Emulator without GPU emulation detected.
05-22 03:13:56.522: I/124312(2124): sfsdfsfasfscfsd cfsearbsd
05-22 03:13:56.533: D/for(2124): ******************for성공*****************
05-22 03:13:56.533: D/AndroidRuntime(2124): Shutting down VM
05-22 03:13:56.533: W/dalvikvm(2124): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
05-22 03:13:56.541: E/AndroidRuntime(2124): FATAL EXCEPTION: main
05-22 03:13:56.541: E/AndroidRuntime(2124): java.lang.NullPointerException
05-22 03:13:56.541: E/AndroidRuntime(2124): at com.tabactivity.TabLayoutActivity$1.onClick(TabLayoutActivity.java:95)
05-22 03:13:56.541: E/AndroidRuntime(2124): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
05-22 03:13:56.541: E/AndroidRuntime(2124): at android.os.Handler.dispatchMessage(Handler.java:99)
05-22 03:13:56.541: E/AndroidRuntime(2124): at android.os.Looper.loop(Looper.java:137)
05-22 03:13:56.541: E/AndroidRuntime(2124): at android.app.ActivityThread.main(ActivityThread.java:4745)
05-22 03:13:56.541: E/AndroidRuntime(2124): at java.lang.reflect.Method.invokeNative(Native Method)
05-22 03:13:56.541: E/AndroidRuntime(2124): at java.lang.reflect.Method.invoke(Method.java:511)
05-22 03:13:56.541: E/AndroidRuntime(2124): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-22 03:13:56.541: E/AndroidRuntime(2124): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-22 03:13:56.541: E/AndroidRuntime(2124): at dalvik.system.NativeStart.main(Native Method)