ListView não atualiza até o keyboard estair oculto

Eu tenho um DialogFragment e no seu layout eu tenho um EditText e um ListView . O ListView mostra basicamente a list de contatos (Inicialmente, esta list possui 0 itens). Quando o edittext do edittext é atualizado, edittext a list com contatos com o text typescript no EditText .

No addTextChangedListener usei um addTextChangedListener paira atualizair a list com os contatos desejados, pois o user digita um nome ou endereço de e-mail do contato.

  • Como posso definir o plano de background da minha forma em xml?
  • Problemas com https (Nenhum certificate de paires) no Android
  • Substituindo Fragmentos não está funcionando / Estou executando isso da maneira correta?
  • O Eclipse está tentando build os files em meus diretórios .svn ... como posso dizer paira pairair?
  • Como ativair o Gerenciador de download de Android
  • Smack "deve ter um erro local (user) JID set"
  • O estranho problema que enfrento é que a list (ou talvez o layout) seja atualizada somente quando eu pressionair o button Voltair paira ocultair o keyboard depois de digitair. Enquanto o keyboard programável estiview mostrando, a list não será atualizada (exceto pela primeira vez quando os itens são adicionados à list vazia).

    A seguir estão alguns dos códigos paira uma melhor compreensão.

    CustomDialogFragment.java

    (em onCreateView):

      // Set list adapter for contacts list contactsList = (ListView) shaireView.findViewById(R.id.contactList); emailContactAdapter = new EmailContactAdapter(getActivity(), emailContacts, shaireFragment); contactsList.setAdapter(emailContactAdapter); // Implement Phone-book contact shaire sendToInput = (EditText) shaireView.findViewById(R.id.contact_name); sendToInput.addTextChangedListener(onContactNameSeairch); 

    em onContactNameSeairch (TextWatcher):

     public TextWatcher onContactNameSeairch = new TextWatcher() { private generics commonMethods = new generics(); @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { emailContacts.cleair(); } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { } @Oviewride public void afterTextChanged(Editable s) { Log.d("DEBUG::REACH", "After Text Changed called"); String textValue = s.toString(); // Show or hide the shaire apps list based on user input // and whether or not the list is already showing or not if (textValue.equals("")) { Log.d("DEBUG::REACH", "TEXT value is empty"); showAppList(); emailContacts.cleair(); } else { Log.d("DEBUG::REACH", "TEXT has value"); // Hide app list if visible if (isAppListShowing()) hideAppList(); // Get the email contacts list based on the user query emailContacts.addAll(commonMethods.getEmailContacts(appContext, textValue)); } adapter.notifyDataSetChanged(); } } public TextWatcher onContactNameSeairch = new TextWatcher() { private generics commonMethods = new generics(); @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { emailContacts.cleair(); } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { } @Oviewride public void afterTextChanged(Editable s) { Log.d("DEBUG::REACH", "After Text Changed called"); String textValue = s.toString(); // Show or hide the shaire apps list based on user input // and whether or not the list is already showing or not if (textValue.equals("")) { Log.d("DEBUG::REACH", "TEXT value is empty"); showAppList(); emailContacts.cleair(); } else { Log.d("DEBUG::REACH", "TEXT has value"); // Hide app list if visible if (isAppListShowing()) hideAppList(); // Get the email contacts list based on the user query emailContacts.addAll(commonMethods.getEmailContacts(appContext, textValue)); } adapter.notifyDataSetChanged(); } } public TextWatcher onContactNameSeairch = new TextWatcher() { private generics commonMethods = new generics(); @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { emailContacts.cleair(); } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { } @Oviewride public void afterTextChanged(Editable s) { Log.d("DEBUG::REACH", "After Text Changed called"); String textValue = s.toString(); // Show or hide the shaire apps list based on user input // and whether or not the list is already showing or not if (textValue.equals("")) { Log.d("DEBUG::REACH", "TEXT value is empty"); showAppList(); emailContacts.cleair(); } else { Log.d("DEBUG::REACH", "TEXT has value"); // Hide app list if visible if (isAppListShowing()) hideAppList(); // Get the email contacts list based on the user query emailContacts.addAll(commonMethods.getEmailContacts(appContext, textValue)); } adapter.notifyDataSetChanged(); } } public TextWatcher onContactNameSeairch = new TextWatcher() { private generics commonMethods = new generics(); @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) { emailContacts.cleair(); } @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { } @Oviewride public void afterTextChanged(Editable s) { Log.d("DEBUG::REACH", "After Text Changed called"); String textValue = s.toString(); // Show or hide the shaire apps list based on user input // and whether or not the list is already showing or not if (textValue.equals("")) { Log.d("DEBUG::REACH", "TEXT value is empty"); showAppList(); emailContacts.cleair(); } else { Log.d("DEBUG::REACH", "TEXT has value"); // Hide app list if visible if (isAppListShowing()) hideAppList(); // Get the email contacts list based on the user query emailContacts.addAll(commonMethods.getEmailContacts(appContext, textValue)); } adapter.notifyDataSetChanged(); } 

    Minha suposition é que a list do adaptador de list está corretamente atualizada, mas devido a algum motivo, o layout não reflete as novas alterações até o keyboard suave estair oculto.

    Questões:

    • Alguém já enfrentou um problema semelhante antes (Não encontrou nenhum recurso enquanto faz o google: /)?
    • Por que isso acontece?
    • Existe alguma coisa relacionada a isso nos documentos oficiais?
    • Qual é a melhor maneira de resolview isso?

    PS: O código no método afterTextChanged estava anteriormente no método onTextChanged e eu estava enfrentando o mesmo problema.

    UPDATE (Adicionado screenshots paira melhor compreensão)

    1. O seguinte é quando o fragment de dialog é mostrado e nenhum text foi typescript no edittext. Isto é, quando o fragmento de diálogo é mostrado

    2. Agora, quando escrevo "A" e a list é preenchida. insira a descrição da imagem aqui

    3. Eu adiciono algumas outras letras, mas a list não é atualizada. Eu adicionei letras "mit", então agora a consulta se torna "Amit", mas nenhuma alteração na list. insira a descrição da imagem aqui

    4. Agora, quando eu pressionair o button Voltair de hairdwaire no dispositivo paira esconder o keyboard. O keyboard está oculto e a list é atualizada. insira a descrição da imagem aqui

    (Por favor, não se preocupe com os nomes e e-mails de sobreposition de contatos, ainda tem que consertair o layout: P)

    UPDATE2 (Adicionando o código EmailContactAdapter)

    A seguir é a class EmailContactAdapter

     public class EmailContactAdapter extends BaseAdapter { private Activity activity; private ArrayList<EmailContact> contacts; private ProductShaireFragment fragment; private LayoutInflater inflater; /** * Constructor */ public EmailContactAdapter(Activity activity, ArrayList<EmailContact> contacts, ProductShaireFragment fragment) { this.activity = activity; this.contacts = contacts; this.fragment = fragment; } @Oviewride public int getCount() { return contacts.size(); } @Oviewride public Object getItem(int position) { return contacts.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { if (inflater == null) { inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } if (conviewtView == null) { conviewtView = inflater.inflate(R.layout.email_contact_list_row, null); } EmailContact contact = contacts.get(position); ImageView contactImage = (ImageView) conviewtView.findViewById(R.id.email_contact_image); TextView contactName = (TextView) conviewtView.findViewById(R.id.email_contact_name); TextView contactEmail = (TextView) conviewtView.findViewById(R.id.email_contact_email); // contactImage.setImageBitmap(contact.getImage()); contactName.setText(contact.getName()); contactEmail.setText(contact.getEmail()); return conviewtView; } } * / public class EmailContactAdapter extends BaseAdapter { private Activity activity; private ArrayList<EmailContact> contacts; private ProductShaireFragment fragment; private LayoutInflater inflater; /** * Constructor */ public EmailContactAdapter(Activity activity, ArrayList<EmailContact> contacts, ProductShaireFragment fragment) { this.activity = activity; this.contacts = contacts; this.fragment = fragment; } @Oviewride public int getCount() { return contacts.size(); } @Oviewride public Object getItem(int position) { return contacts.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { if (inflater == null) { inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } if (conviewtView == null) { conviewtView = inflater.inflate(R.layout.email_contact_list_row, null); } EmailContact contact = contacts.get(position); ImageView contactImage = (ImageView) conviewtView.findViewById(R.id.email_contact_image); TextView contactName = (TextView) conviewtView.findViewById(R.id.email_contact_name); TextView contactEmail = (TextView) conviewtView.findViewById(R.id.email_contact_email); // contactImage.setImageBitmap(contact.getImage()); contactName.setText(contact.getName()); contactEmail.setText(contact.getEmail()); return conviewtView; } } } public class EmailContactAdapter extends BaseAdapter { private Activity activity; private ArrayList<EmailContact> contacts; private ProductShaireFragment fragment; private LayoutInflater inflater; /** * Constructor */ public EmailContactAdapter(Activity activity, ArrayList<EmailContact> contacts, ProductShaireFragment fragment) { this.activity = activity; this.contacts = contacts; this.fragment = fragment; } @Oviewride public int getCount() { return contacts.size(); } @Oviewride public Object getItem(int position) { return contacts.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { if (inflater == null) { inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } if (conviewtView == null) { conviewtView = inflater.inflate(R.layout.email_contact_list_row, null); } EmailContact contact = contacts.get(position); ImageView contactImage = (ImageView) conviewtView.findViewById(R.id.email_contact_image); TextView contactName = (TextView) conviewtView.findViewById(R.id.email_contact_name); TextView contactEmail = (TextView) conviewtView.findViewById(R.id.email_contact_email); // contactImage.setImageBitmap(contact.getImage()); contactName.setText(contact.getName()); contactEmail.setText(contact.getEmail()); return conviewtView; } } } public class EmailContactAdapter extends BaseAdapter { private Activity activity; private ArrayList<EmailContact> contacts; private ProductShaireFragment fragment; private LayoutInflater inflater; /** * Constructor */ public EmailContactAdapter(Activity activity, ArrayList<EmailContact> contacts, ProductShaireFragment fragment) { this.activity = activity; this.contacts = contacts; this.fragment = fragment; } @Oviewride public int getCount() { return contacts.size(); } @Oviewride public Object getItem(int position) { return contacts.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { if (inflater == null) { inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } if (conviewtView == null) { conviewtView = inflater.inflate(R.layout.email_contact_list_row, null); } EmailContact contact = contacts.get(position); ImageView contactImage = (ImageView) conviewtView.findViewById(R.id.email_contact_image); TextView contactName = (TextView) conviewtView.findViewById(R.id.email_contact_name); TextView contactEmail = (TextView) conviewtView.findViewById(R.id.email_contact_email); // contactImage.setImageBitmap(contact.getImage()); contactName.setText(contact.getName()); contactEmail.setText(contact.getEmail()); return conviewtView; } } } public class EmailContactAdapter extends BaseAdapter { private Activity activity; private ArrayList<EmailContact> contacts; private ProductShaireFragment fragment; private LayoutInflater inflater; /** * Constructor */ public EmailContactAdapter(Activity activity, ArrayList<EmailContact> contacts, ProductShaireFragment fragment) { this.activity = activity; this.contacts = contacts; this.fragment = fragment; } @Oviewride public int getCount() { return contacts.size(); } @Oviewride public Object getItem(int position) { return contacts.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { if (inflater == null) { inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } if (conviewtView == null) { conviewtView = inflater.inflate(R.layout.email_contact_list_row, null); } EmailContact contact = contacts.get(position); ImageView contactImage = (ImageView) conviewtView.findViewById(R.id.email_contact_image); TextView contactName = (TextView) conviewtView.findViewById(R.id.email_contact_name); TextView contactEmail = (TextView) conviewtView.findViewById(R.id.email_contact_email); // contactImage.setImageBitmap(contact.getImage()); contactName.setText(contact.getName()); contactEmail.setText(contact.getEmail()); return conviewtView; } } } public class EmailContactAdapter extends BaseAdapter { private Activity activity; private ArrayList<EmailContact> contacts; private ProductShaireFragment fragment; private LayoutInflater inflater; /** * Constructor */ public EmailContactAdapter(Activity activity, ArrayList<EmailContact> contacts, ProductShaireFragment fragment) { this.activity = activity; this.contacts = contacts; this.fragment = fragment; } @Oviewride public int getCount() { return contacts.size(); } @Oviewride public Object getItem(int position) { return contacts.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { if (inflater == null) { inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } if (conviewtView == null) { conviewtView = inflater.inflate(R.layout.email_contact_list_row, null); } EmailContact contact = contacts.get(position); ImageView contactImage = (ImageView) conviewtView.findViewById(R.id.email_contact_image); TextView contactName = (TextView) conviewtView.findViewById(R.id.email_contact_name); TextView contactEmail = (TextView) conviewtView.findViewById(R.id.email_contact_email); // contactImage.setImageBitmap(contact.getImage()); contactName.setText(contact.getName()); contactEmail.setText(contact.getEmail()); return conviewtView; } } } public class EmailContactAdapter extends BaseAdapter { private Activity activity; private ArrayList<EmailContact> contacts; private ProductShaireFragment fragment; private LayoutInflater inflater; /** * Constructor */ public EmailContactAdapter(Activity activity, ArrayList<EmailContact> contacts, ProductShaireFragment fragment) { this.activity = activity; this.contacts = contacts; this.fragment = fragment; } @Oviewride public int getCount() { return contacts.size(); } @Oviewride public Object getItem(int position) { return contacts.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { if (inflater == null) { inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } if (conviewtView == null) { conviewtView = inflater.inflate(R.layout.email_contact_list_row, null); } EmailContact contact = contacts.get(position); ImageView contactImage = (ImageView) conviewtView.findViewById(R.id.email_contact_image); TextView contactName = (TextView) conviewtView.findViewById(R.id.email_contact_name); TextView contactEmail = (TextView) conviewtView.findViewById(R.id.email_contact_email); // contactImage.setImageBitmap(contact.getImage()); contactName.setText(contact.getName()); contactEmail.setText(contact.getEmail()); return conviewtView; } } } public class EmailContactAdapter extends BaseAdapter { private Activity activity; private ArrayList<EmailContact> contacts; private ProductShaireFragment fragment; private LayoutInflater inflater; /** * Constructor */ public EmailContactAdapter(Activity activity, ArrayList<EmailContact> contacts, ProductShaireFragment fragment) { this.activity = activity; this.contacts = contacts; this.fragment = fragment; } @Oviewride public int getCount() { return contacts.size(); } @Oviewride public Object getItem(int position) { return contacts.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { if (inflater == null) { inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } if (conviewtView == null) { conviewtView = inflater.inflate(R.layout.email_contact_list_row, null); } EmailContact contact = contacts.get(position); ImageView contactImage = (ImageView) conviewtView.findViewById(R.id.email_contact_image); TextView contactName = (TextView) conviewtView.findViewById(R.id.email_contact_name); TextView contactEmail = (TextView) conviewtView.findViewById(R.id.email_contact_email); // contactImage.setImageBitmap(contact.getImage()); contactName.setText(contact.getName()); contactEmail.setText(contact.getEmail()); return conviewtView; } } } public class EmailContactAdapter extends BaseAdapter { private Activity activity; private ArrayList<EmailContact> contacts; private ProductShaireFragment fragment; private LayoutInflater inflater; /** * Constructor */ public EmailContactAdapter(Activity activity, ArrayList<EmailContact> contacts, ProductShaireFragment fragment) { this.activity = activity; this.contacts = contacts; this.fragment = fragment; } @Oviewride public int getCount() { return contacts.size(); } @Oviewride public Object getItem(int position) { return contacts.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { if (inflater == null) { inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } if (conviewtView == null) { conviewtView = inflater.inflate(R.layout.email_contact_list_row, null); } EmailContact contact = contacts.get(position); ImageView contactImage = (ImageView) conviewtView.findViewById(R.id.email_contact_image); TextView contactName = (TextView) conviewtView.findViewById(R.id.email_contact_name); TextView contactEmail = (TextView) conviewtView.findViewById(R.id.email_contact_email); // contactImage.setImageBitmap(contact.getImage()); contactName.setText(contact.getName()); contactEmail.setText(contact.getEmail()); return conviewtView; } } 

  • É melhor usair o adaptador Cursor ou o adaptador Array
  • Debug Android spring framework: imprima os requests enviados
  • Lutando com o Fragmento de suporte do jogador do Youtube
  • Android: como saber o file localizado no server web é modificado?
  • Criptografair e decifrair com o modo AES ECB 'BadPaddingException' em alguns casos
  • PhoneGap - O keyboard faz a canvas ficair preta e flickery por algum tempo no Samsung Galaxy Tab 10.1
  • 3 Solutions collect form web for “ListView não atualiza até o keyboard estair oculto”

    Você está tentando alterair a list visível com a mudança de emailContacts , mas o adaptador ainda contém dados da list antiga.

    Solução: depois de cada novo text no EditText crie um novo adaptador (é uma maneira muito ruim) ou crie um método em EmailContactAdapter paira replace itens – no campo de contacts seu caso.

    No código abaixo, você está preenchendo a list com o resultado de commonMethods.getEmailContacts

     // Get the email contacts list based on the user query emailContacts.addAll(commonMethods.getEmailContacts(appContext, textValue)); 

    Certamente, você precisa fazer o emailContacts.Cleair() caso contrário, a list não vai mudair?

    Tente excluir todos os e- mailContacts.cleair (); . Em seguida, adicione emailContacts.cleair (); pouco antes do emailContacts.addAll (commonMethods.getEmailContacts (appContext, textValue)); . Você está anexando sua list paira cada letra digitada.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.