//このreturnの値であるnullを、下の、Log出力時のように、etoと表示されるようにしたいです。どこでreturnをすれば、etoをusernameに代入しreturnできるのでしょうか?
java
1 206-10 05:50:02.567 17954-17954/com.example.android.sample.new3 I/System.out: return username;:null 3 406-10 05:50:07.603 17954-17954/com.example.android.sample.new3 I/System.out: select username from user where username = 'eto' and password = 'eto'; 506-10 05:50:07.624 17954-17954/com.example.android.sample.new3 I/System.out: checkusername:eto 606-10 05:50:07.624 17954-17954/com.example.android.sample.new3 I/System.out: username:eto 706-10 05:50:07.624 17954-17954/com.example.android.sample.new3 I/System.out: ログイン完了eto 8
java
1 public String newSet(LayoutInflater inflaters, final Context contexts,View layouts,InputMethodManager inputMethodManagers) { 2 3 4 builder = new AlertDialog.Builder(context); 5 builder.setView(layout); 6 builder.setNegativeButton("ログイン", new DialogInterface.OnClickListener() { 7 public void onClick(DialogInterface dialog, int which) { 8 EditText getusername2 = (EditText) layout.findViewById(R.id.username); 9 String getusername = getusername2.getText().toString(); 10 11 //データベースから取得してあればログイン 12 String sql = "select username from user where username = '" + getusername + "';"; 13 System.out.println(sql);/////////////////////ログ出力 14 MyOpenHelper helper = new MyOpenHelper(context); 15 SQLiteDatabase db = helper.getWritableDatabase(); 16 Cursor c = db.rawQuery(sql, null); 17 Integer count = c.getCount(); 18 if (count != 0) { 19 c.moveToFirst(); 20 String checkusername = c.getString(0); 21 Toast toast = Toast.makeText(context, "ログインしました", Toast.LENGTH_SHORT); 22 toast.show(); 23 System.out.println("checkusername:"+checkusername);/////////////////////ログ出力 24 username = checkusername; 25 System.out.println("username:"+username);/////////////////////ログ出力 26 System.out.println("ログイン完了" + username);/////////////////////ログ出力 27 } 28 29 }); 30 alertDialog = builder.create(); 31 alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { 32 33 @Override 34 public void onShow(DialogInterface arg0) { 35 getusername2 = (EditText) layout.findViewById(R.id.username); 36 //inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 37 inputMethodManager.showSoftInput(getusername2, 0); 38 } 39 40 }); 41 alertDialog.show(); 42 43 System.out.println("return usernmae;:"+username);/////////////////////ログ出力 44 return username; 45 46 }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/11 17:46
2017/06/12 03:49
2017/06/12 09:23