2013-01-20 47 views
0

在logcat中沒有錯誤,但建議列表不會顯示我不確定我出錯的地方。我在提醒對話框中填充了自動填充視圖。這是我下面自動完成文本框不會顯示建議

reg_btn.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View v) { 


       final String[] devplatforms = 
        { 
        "C", 
        "C++", 
        "Java", 
        "iPhone", 
        "Android", 
        "ASP.NET", 
        "PHP", 
        "Python", 
        }; 


       AlertDialog.Builder adb = new AlertDialog.Builder(SettingsMain.this); 
       LayoutInflater inflater = SettingsMain.this.getLayoutInflater(); 
       final View searchlayout = inflater.inflate(R.layout.search_friend, null); 

       adb.setView(searchlayout) 

       .setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int whichButton) { 
         AutoCompleteTextView friend_name; 
         friend_name = (AutoCompleteTextView) searchlayout.findViewById(R.id.friend_name); 
         friend_name.setThreshold(1); 
         friend_name.setAdapter(new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_dropdown_item_1line,devplatforms)); 

         String name = friend_name.getText().toString(); 
         Log.d("ECHO" , "Pin Value : " + name); 
         return;     
         } 
        }) 
       .setNegativeButton("Done", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int id) { 


         dialog.cancel(); 
        } 
       }); 

        adb.show(); 

    }); 

回答

2

代碼它看起來像這樣的代碼是在錯誤的地方:

AutoCompleteTextView friend_name; 
friend_name = (AutoCompleteTextView) searchlayout.findViewById(R.id.friend_name); 
friend_name.setThreshold(1); 
friend_name.setAdapter(new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_dropdown_item_1line,devplatforms)); 

移動它上面這一行:

adb.setView(searchlayout) 

你充氣的佈局,但你只在AutoCompleteTextView適配器中通過「Ok」按鈕...在顯示對話框之前設置AutoCompleteTextView

+0

哇,這真是石頭。我需要恢復自己的注意力,用一些冰水洗臉,然後重新開始工作。感謝您的簡單更正,以解釋情況。 – kabuto178