質問編集履歴

1

余計なko-dowosakuzixyo

2017/06/09 23:16

投稿

edoooooo
edoooooo

スコア476

test CHANGED
File without changes
test CHANGED
@@ -24,11 +24,11 @@
24
24
 
25
25
  ```java
26
26
 
27
- public String newSet(LayoutInflater inflaters, final Context contexts,View layouts,InputMethodManager inputMethodManagers) {
27
+ public String newSet(LayoutInflater inflaters, final Context contexts,View layouts,InputMethodManager inputMethodManagers) {
28
28
 
29
29
 
30
30
 
31
-
31
+
32
32
 
33
33
  builder = new AlertDialog.Builder(context);
34
34
 
@@ -36,85 +36,73 @@
36
36
 
37
37
  builder.setNegativeButton("ログイン", new DialogInterface.OnClickListener() {
38
38
 
39
- public void onClick(DialogInterface dialog, int which) {
39
+ public void onClick(DialogInterface dialog, int which) {
40
40
 
41
- EditText getusername2 = (EditText) layout.findViewById(R.id.username);
41
+ EditText getusername2 = (EditText) layout.findViewById(R.id.username);
42
42
 
43
- EditText getpassword2 = (EditText) layout.findViewById(R.id.password);
43
+ String getusername = getusername2.getText().toString();
44
44
 
45
- String getusername = getusername2.getText().toString();
45
+
46
46
 
47
- String password = getpassword2.getText().toString();
47
+ //データベースから取得してあればログイン
48
48
 
49
- //データベースから取得してあればログイン
49
+ String sql = "select username from user where username = '" + getusername + "';";
50
50
 
51
- String sql = "select username from user where username = '" + getusername + "' and password = '" + password + "';";
51
+ System.out.println(sql);/////////////////////ログ出力
52
52
 
53
- System.out.println(sql);/////////////////////ログ出力
53
+ MyOpenHelper helper = new MyOpenHelper(context);
54
54
 
55
- MyOpenHelper helper = new MyOpenHelper(context);
55
+ SQLiteDatabase db = helper.getWritableDatabase();
56
56
 
57
- SQLiteDatabase db = helper.getWritableDatabase();
57
+ Cursor c = db.rawQuery(sql, null);
58
58
 
59
- Cursor c = db.rawQuery(sql, null);
59
+ Integer count = c.getCount();
60
60
 
61
- Integer count = c.getCount();
61
+ if (count != 0) {
62
62
 
63
- if (count != 0) {
63
+ c.moveToFirst();
64
64
 
65
- c.moveToFirst();
65
+ String checkusername = c.getString(0);
66
66
 
67
- String checkusername = c.getString(0);
67
+ Toast toast = Toast.makeText(context, "ログインしました", Toast.LENGTH_SHORT);
68
68
 
69
- //ログインする
69
+ toast.show();
70
70
 
71
- Toast toast = Toast.makeText(context, "ログインしました", Toast.LENGTH_SHORT);
71
+ System.out.println("checkusername:"+checkusername);/////////////////////ログ出力
72
72
 
73
- toast.show();
73
+ username = checkusername;
74
74
 
75
- //そして、usernameset
75
+ System.out.println("username:"+username);/////////////////////ログ出力
76
76
 
77
- System.out.println("checkusername:"+checkusername);/////////////////////ログ出力
77
+ System.out.println("ログイン完了" + username);/////////////////////ログ出力
78
78
 
79
- username = checkusername;
79
+ }
80
-
81
- System.out.println("username:"+username);/////////////////////ログ出力
82
-
83
- System.out.println("ログイン完了" + username);/////////////////////ログ出力
84
-
85
-
86
80
 
87
81
 
88
82
 
89
- }
83
+ });
90
84
 
91
-
92
-
93
- });
94
-
95
- alertDialog = builder.create();
85
+ alertDialog = builder.create();
96
86
 
97
87
  alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
98
88
 
99
89
 
100
90
 
91
+ @Override
101
92
 
93
+ public void onShow(DialogInterface arg0) {
102
94
 
103
- @Override
95
+ getusername2 = (EditText) layout.findViewById(R.id.username);
104
96
 
105
- public void onShow(DialogInterface arg0) {
97
+ //inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
106
98
 
107
- getusername2 = (EditText) layout.findViewById(R.id.username);
99
+ inputMethodManager.showSoftInput(getusername2, 0);
108
100
 
109
- //inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
110
-
111
- inputMethodManager.showSoftInput(getusername2, 0);
112
-
113
- }
101
+ }
114
102
 
115
103
 
116
104
 
117
- });
105
+ });
118
106
 
119
107
  alertDialog.show();
120
108