0

데이터베이스 테이블의 결과를 갖는 자동 완성 텍스트 뷰에 onclicklister를 구현하고 싶습니다.
나는 그것을 봤지만, 정확히 내가 원하는 것을 얻지 못했다. stackoverflow link.

내 autocompletetetextview에서 사용자 이름을 표시하고 선택한 항목을 클릭하면 사용자 세부 정보 페이지가 열립니다. 사용자 이름과 ID는 사용자 테이블에서 가져 오지만 표시해야합니다. 이름을 해당 사용자 아이디로 autocompletetextview에 저장하면 요청을 보내고 사용자 정보 화면을 엽니 다.

미리 감사드립니다.데이터베이스 및 onitemclicklister에서 autocompletetextview 목록 표시

답변

1

두 개의 배열을 유지하십시오. 하나는 사용자 이름이고 다른 하나는 id입니다. 이제 데이터베이스에서 값을 얻는 방법을 알고 있다고 생각합니다 ... edittext 필드와 그 아래에 listview를 두십시오. 결과는 그 목록보기에 표시 할 ... 지금 ..

s1=""; 
    s2=youredittext.getText().toString(); 
    new Thread(new Runnable() { 
      public void run() { 

      while(bool){ 

       s2=youredittext.getText().toString(); 
      if(s1!=s2 && s2.length()>=1){ 

       s1=s2; 
         //here search the database for the name starting with the string in s1 and get the user name and id fields..and populate the arrays... 
          } 
          runOnUiThread(new Runnable() { 
        public void run() { 
         adapter.clear();<--- this will clear the list every time a new letter is added or removed from the edittext.. and add relevent items.. 
         for(int z=0;z<namesarray.length;z++){ 

          adapter.add(namesarray[z]); 
         } 
         adapter.notifyDataSetChanged(); 



        } 
       }); 
    }}).start(); 

을 지속적으로 다음과 같이 있습니다 .. 글고에서 문자열을 확인합니다 스레드를 만들고 모든 항목을 클릭하면 해당 목록에서 항목의 위치를 ​​얻을 수 .. 그리고 해당 인덱스의 항목에 ids 배열은 해당 ID가됩니다.

관련 문제