質問編集履歴
5
やりたいことの説明を追加
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         @@ -1,3 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            やりたいこととしましては、
         
     | 
| 
      
 2 
     | 
    
         
            +
            ログインをするためのAlertDialogが表示された時に、
         
     | 
| 
      
 3 
     | 
    
         
            +
            usernameとpasswordを入力するためのソフトウェアキーボードが表示されるようにすることです。
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       1 
8 
     | 
    
         
             
            ソフトキーボードを表示するためにonShow()を作ったのですが、create()に、can not resolve alertDialogBuilderと出ます。
         
     | 
| 
       2 
9 
     | 
    
         | 
| 
       3 
10 
     | 
    
         
             
            もともとは、 AlertDialog.Builder builder = new AlertDialog.Builder(this);を使っていたのですが、onShow()は、alertDialogBuilderをcreate()する方法でしか使えないと見たのですが、どうすれば、alertDialogBuilderをcreate()ができるでしょうか
         
     | 
4
説明の追加
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         @@ -16,6 +16,8 @@ 
     | 
|
| 
       16 
16 
     | 
    
         
             
            ```
         
     | 
| 
       17 
17 
     | 
    
         
             
            できれば、alertDialogBuilder.create();を使わずに、 AlertDialog.Builder builder = new AlertDialog.Builder(this);を使ってコードを書きたいのですが、onShow()を使わないとソフトキーボードを表示することはできないのでしょうか?
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
      
 19 
     | 
    
         
            +
            下のコードは、ソフトキーボードを表示するためのコードです。3つの方法を試しましたが、表示できませんでした。
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       19 
21 
     | 
    
         
             
            ```java
         
     | 
| 
       20 
22 
     | 
    
         
             
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
         
     | 
| 
       21 
23 
     | 
    
         
             
                        builder.setView(layout);
         
     | 
3
誤字
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ソフトキーボードを表示するため 
     | 
| 
      
 1 
     | 
    
         
            +
            ソフトキーボードを表示するためにonShow()を作ったのですが、create()に、can not resolve alertDialogBuilderと出ます。
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            もともとは、 AlertDialog.Builder builder = new AlertDialog.Builder(this);を使っていたのですが、onShow()は、alertDialogBuilderをcreate()する方法でしか使えないと見たのですが、どうすれば、alertDialogBuilderをcreate()ができるでしょうか
         
     | 
| 
       4 
4 
     | 
    
         | 
2
もともとは、AlertDialog\.Builder builder = new AlertDialog\.Builder\(this\);を使ってコードを書いています
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         @@ -1,9 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ソフトキーボードを表示するためのShow()を作ったのですが、create()に、can not resolve alertDialogBuilderと出ます。
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            もともとは、 AlertDialog.Builder builder = new AlertDialog.Builder(this);を使っていたのですが、onShow()は、alertDialogBuilderをcreate()する方法でしか使えないと見たのですが、どうすれば、alertDialogBuilderをcreate()ができるでしょうか 
     | 
| 
      
 3 
     | 
    
         
            +
            もともとは、 AlertDialog.Builder builder = new AlertDialog.Builder(this);を使っていたのですが、onShow()は、alertDialogBuilderをcreate()する方法でしか使えないと見たのですが、どうすれば、alertDialogBuilderをcreate()ができるでしょうか
         
     | 
| 
       4 
     | 
    
         
            -
            ソフトキーボードを表示する方法はないでしょうか?
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
5 
     | 
    
         
             
            ```java
         
     | 
| 
       8 
6 
     | 
    
         
             
            //ソフトキーボードを表示するためのShow()です。
         
     | 
| 
       9 
7 
     | 
    
         
             
               AlertDialog alertDialog = alertDialogBuilder.create();
         
     | 
| 
         @@ -15,4 +13,22 @@ 
     | 
|
| 
       15 
13 
     | 
    
         
             
                                inputMethodManager.showSoftInput(getusername2, 0);
         
     | 
| 
       16 
14 
     | 
    
         
             
                            }
         
     | 
| 
       17 
15 
     | 
    
         
             
                        });
         
     | 
| 
      
 16 
     | 
    
         
            +
            ```
         
     | 
| 
      
 17 
     | 
    
         
            +
            できれば、alertDialogBuilder.create();を使わずに、 AlertDialog.Builder builder = new AlertDialog.Builder(this);を使ってコードを書きたいのですが、onShow()を使わないとソフトキーボードを表示することはできないのでしょうか?
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            ```java
         
     | 
| 
      
 20 
     | 
    
         
            +
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
         
     | 
| 
      
 21 
     | 
    
         
            +
                        builder.setView(layout);
         
     | 
| 
      
 22 
     | 
    
         
            +
                        EditText getusername2 = (EditText) layout.findViewById(R.id.username);
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                      
         
     | 
| 
      
 25 
     | 
    
         
            +
                        //一つ目の方法
         
     | 
| 
      
 26 
     | 
    
         
            +
                        InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
         
     | 
| 
      
 27 
     | 
    
         
            +
                        inputMethodManager.showSoftInput(getusername2, 0);
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                        //2つ目の方法
         
     | 
| 
      
 30 
     | 
    
         
            +
                        inputMethodManager.toggleSoftInput(1, InputMethodManager.SHOW_IMPLICIT);
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                        //3つ目
         
     | 
| 
      
 33 
     | 
    
         
            +
                        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
         
     | 
| 
       18 
34 
     | 
    
         
             
            ```
         
     | 
1
誤字
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ソフトキーボードを表示するためのShow()を作ったのですが、create()に、can not resolve alertDialogBuilderと出ます。
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            もともとは、 AlertDialog 
     | 
| 
      
 3 
     | 
    
         
            +
            もともとは、 AlertDialog.Builder builder = new AlertDialog.Builder(this);を使っていたのですが、onShow()は、alertDialogBuilderをcreate()する方法でしか使えないと見たのですが、どうすれば、alertDialogBuilderをcreate()ができるでしょうか?また、ほかに、
         
     | 
| 
       4 
4 
     | 
    
         
             
            ソフトキーボードを表示する方法はないでしょうか?
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         |