質問編集履歴
1
余計なko-dowosakuzixyo
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,52 +11,46 @@
|
|
11
11
|
```
|
12
12
|
|
13
13
|
```java
|
14
|
-
public String newSet(LayoutInflater inflaters, final Context contexts,View layouts,InputMethodManager inputMethodManagers) {
|
14
|
+
public String newSet(LayoutInflater inflaters, final Context contexts,View layouts,InputMethodManager inputMethodManagers) {
|
15
15
|
|
16
|
-
|
16
|
+
|
17
17
|
builder = new AlertDialog.Builder(context);
|
18
18
|
builder.setView(layout);
|
19
19
|
builder.setNegativeButton("ログイン", new DialogInterface.OnClickListener() {
|
20
|
-
public void onClick(DialogInterface dialog, int which) {
|
20
|
+
public void onClick(DialogInterface dialog, int which) {
|
21
|
-
|
21
|
+
EditText getusername2 = (EditText) layout.findViewById(R.id.username);
|
22
|
-
EditText getpassword2 = (EditText) layout.findViewById(R.id.password);
|
23
|
-
|
22
|
+
String getusername = getusername2.getText().toString();
|
24
|
-
|
23
|
+
|
25
|
-
|
24
|
+
//データベースから取得してあればログイン
|
26
|
-
|
25
|
+
String sql = "select username from user where username = '" + getusername + "';";
|
27
|
-
|
26
|
+
System.out.println(sql);/////////////////////ログ出力
|
28
|
-
|
27
|
+
MyOpenHelper helper = new MyOpenHelper(context);
|
29
|
-
|
28
|
+
SQLiteDatabase db = helper.getWritableDatabase();
|
30
|
-
|
29
|
+
Cursor c = db.rawQuery(sql, null);
|
31
|
-
|
30
|
+
Integer count = c.getCount();
|
32
|
-
|
31
|
+
if (count != 0) {
|
33
|
-
|
32
|
+
c.moveToFirst();
|
34
|
-
|
33
|
+
String checkusername = c.getString(0);
|
35
|
-
//ログインする
|
36
|
-
|
34
|
+
Toast toast = Toast.makeText(context, "ログインしました", Toast.LENGTH_SHORT);
|
37
|
-
|
35
|
+
toast.show();
|
38
|
-
//そして、usernameにset
|
39
|
-
|
36
|
+
System.out.println("checkusername:"+checkusername);/////////////////////ログ出力
|
40
|
-
|
37
|
+
username = checkusername;
|
41
|
-
|
38
|
+
System.out.println("username:"+username);/////////////////////ログ出力
|
42
|
-
|
39
|
+
System.out.println("ログイン完了" + username);/////////////////////ログ出力
|
43
|
-
|
40
|
+
}
|
44
41
|
|
45
|
-
}
|
46
|
-
|
47
|
-
|
42
|
+
});
|
48
|
-
|
43
|
+
alertDialog = builder.create();
|
49
44
|
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
50
45
|
|
46
|
+
@Override
|
47
|
+
public void onShow(DialogInterface arg0) {
|
48
|
+
getusername2 = (EditText) layout.findViewById(R.id.username);
|
49
|
+
//inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
50
|
+
inputMethodManager.showSoftInput(getusername2, 0);
|
51
|
+
}
|
51
52
|
|
52
|
-
@Override
|
53
|
-
public void onShow(DialogInterface arg0) {
|
54
|
-
getusername2 = (EditText) layout.findViewById(R.id.username);
|
55
|
-
//inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
56
|
-
inputMethodManager.showSoftInput(getusername2, 0);
|
57
|
-
}
|
58
|
-
|
59
|
-
|
53
|
+
});
|
60
54
|
alertDialog.show();
|
61
55
|
|
62
56
|
System.out.println("return usernmae;:"+username);/////////////////////ログ出力
|