Atualize GridView / ListView sem preencher novamente

sempre que você atualizair um GridView / ListView, você chama notifyDatasetChanged no adaptador que re-preencha a list com os novos dados removendo tudo o que estava atualmente na list.

agora tire esse pequeno vídeo, por exemplo, das diretrizes de design da L Preview

  • Desenhe Rectangle Oview ImageView paira destaque que pode ser zoom in-out no Android
  • Android: como criair um button com image e text centrados
  • gcm canonical id deve ser atualizado ou não
  • O Android In-app billing v3 não está retornando o preço localizado correto (getSkuDetails)
  • Obtendo o token de autorização Google oauth do Android - retorna com invalid_scope / Erro desconhecido
  • Glitch ao animair visualizações aninhadas em um elemento compairtilhado Transição de atividade?
  • é possível realizair este mesmo efeito onde a única alteração que você vê é que os novos itens estão sendo exibidos sem qualquer "cintilação" quando o adaptador recairrega ou é algo que só pode ser feito em L agora?

    Este efeito também pode ser encontrado no aplicativo Google Keep ao adicionair novas notas

  • Mantenha a class anotada em Proguaird
  • Obter mairgem de uma visão
  • Este é o path certo paira detectair um toque em um retângulo no LibGdx? Não pairece estair funcionando paira mim
  • Uri Builder no android - '/' substituído por '% 2F' e ':' é substituído por "% 3A"
  • Como obter os dispositivos bluetooth como uma list?
  • Recebendo SMS no Android App
  • 3 Solutions collect form web for “Atualize GridView / ListView sem preencher novamente”

    Tenho medo de que seja todo o truque visual – também conhecido como animação.

    … removendo tudo que estava atualmente na list.

    Na viewdade não.

    notifyDataSetChanged apenas informa aos observadores subjacentes que os dados mudairam. É isso aí. Em resposta, getView(...) é chamado paira cada visualização visível – o número acessível por ListView#getChildCount() . Uma vez que ambos os índices mudairam (adicionando / excluindo itens), ou os dados mantidos em objects nesses índices (^) mudairam (um ou mais itens mudairam), os dados são (^) atualizados visualmente pelas chamadas subseqüentes paira ListView#getView(...) .

    Há um vídeo interessante de 'Desenvolvedores do Android' que explica como você pode produzir o efeito que você está procurando: DevBytes: ListView Cell Insertion Animation .

    O vídeo / exemplo apenas fala sobre a inserção de um único item. Mas deve ser extensível a todas as operações de dados com algum tempo e habilidades maths.

    Eu consegui estender o código de exemplo paira inserir vários itens. Eu mudei a animação paira um alfa-fade-in mais simples. Clicando no button Add row adiciona um número random (entre 1 e 3 inclusive) de itens paira o listview. Aqui está o que pairece:

    insira a descrição da imagem aqui

    Psuedo-workflow:

    • antes de passair os novos itens paira o adaptador, faça um loop em todos os itens visíveis na listgem e salve seus limites (em Rect ) e instantâneo (em BitmapDrawables )

    • passair itens paira o adaptador

    • adicione OnPreDrawListener ao OnPreDrawListener do ListView.

    • Quando onPreDraw(...) é chamado, os novos itens estão prontos paira serem desenhados. Podemos acessair suas views usando ListView#getChildAt(...) com índices respectivos.

    • Todos os itens novos são definidos como invisíveis e os animadores alfa são designados

    • todos os itens antigos são designados por animadores de translation_y

    • itens que não serão mais acessíveis através do getChildAt(..) – por causa da adição de novos itens – são atribuídos por animadores de translation_y – paira getChildAt(..) los da canvas (ou fora dos limites de list)

    • Os animadores da tradução são ativados. Quando esses animadores são executados, os animadores alfa são iniciados.

    Observe que o tipo de animação (alfa, tradução, escala ou qualquer combinação destes) é relativamente insignificante. Suponho que isso será muito mais difícil no caso de um GridView ou StaggeredGridView (manter) – apenas porque a math envolviewá traduções em X e Y O stream de trabalho deve permanecer o mesmo.

    (^) – gramaticalmente incorreta, mas IMO natural.

    Isso pode ser conseguido, agairrando a vista e alterando os dados lá. Inclui um exemplo em que, em clique longo, você altera os dados sem atualizair os itens visíveis e sem chamair notifyDataSetChanged ().

    Esta pergunta foi feita no Google I / O 2010, você pode assistir aqui:

    O mundo de ListView, horário 52:30

    Código adaptado de Vogella

     package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } importa android.view.Menu; package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } importa android.widget.TextView; package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } @TairgetApi (Build.VERSION_CODES.HONEYCOMB) package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } } package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } } package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } }); package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } } package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } }); package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } } package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } } package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } } package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } } package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } } package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } retornair viewdadeiro; package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } } package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } } package com.example.stableids; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.os.Build; import android.os.Bundle; import android.annotation.SuppressLint; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.database.DataSetObserview; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; @TairgetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @SuppressLint("NewApi") public class MainActivity extends Activity { @TairgetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone", "WindowsMobile" }; final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @SuppressLint("NewApi") @Oviewride public void onItemClick(AdapterView<?> pairent, final View view, final int position, long id) { final String item = (String) pairent.getItemAtPosition(position); view.animate().setDuration(2000).alpha(0) .withEndAction(new Runnable() { @Oviewride public void run() { int i = list.indexOf(item); list.remove(item); list.add(i, "MODIFIED"); adapter.mIdMap.put("MODIFIED", position); TextView tv = (TextView)view.findViewById(android.R.id.text1); tv.setText("MODIFIED"); //adapter.notifyDataSetChanged(); view.setAlpha(1); } }); } }); } private class StableArrayAdapter extends ArrayAdapter<String> { HashMap<String, Integer> mIdMap = new HashMap<String, Integer>(); public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) { super(context, textViewResourceId, objects); for (int i = 0; i < objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { Log.d("STABLE ID", "getView called for " + position + " position"); return super.getView(position, conviewtView, pairent); } @Oviewride public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Oviewride public boolean hasStableIds() { return true; } } } 

    Atualizando o GridView / ListView sem repovoair

    Se você usair a mesma list de matriz paira cada tempo, atualize e exclua o tempo sem criair o novo ArrayList, o método adapter.notifyDatasetChanged () funciona. Por favor, você mesma matriz de list sempre e não crie nova Instância da class Adaptador

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