android – Change the text of a TextView that is inside an ArrayAdapter item


I made an Adapter that extends from ArrayAdapter . My layout only contains a series of TextViews , one below the other, very simple.

I want any event in the system to be observed by my Adapter and for a certain item in the list to be changed. For that I'm using EventBus .

In my Adapter constructor I use EventBus.getDefault().register(this);

The Adapter has an onEvent(MessageRunTask event){...}

I created a Job to run and test, it runs EventBus.getDefault().post(new MessageRunTask(r)); when it finishes, and using Log.i I can confirm that the Adapter 's onEvent onEvent is running successfully.

What I don't know how to do is:

Inside the onEvent method, how do I get item X from the list and update TextView Y's Text property that is inside that item X?


Here is the Adapter code with the tried solutions:

public class TarefaAdapter extends ArrayAdapter<Tarefa> {

    private List<Tarefa> items;
    private int layoutResourceId;
    private Context context;
    private List<View> itensExibidos;

    public TarefaAdapter(Context context, int layoutResourceId, List<Tarefa> items) {
        super(context, layoutResourceId, items);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.items = items;

        this.itensExibidos = new ArrayList<View>();



    public void onEvent(MessageRunTask event){

        if (!itensExibidos.isEmpty()) {

            //ESSE LOG APARECE
            Log.i("DEBUGEVENT", " teste");

            //TENTATIVA 1
            View v = itensExibidos.get(0);
            TarefasHolder ta = (TarefasHolder) v.getTag();
            ta.url.setText("Teste texto");

            //TENTATIVA 2
            TextView t = (TextView)v.findViewById(;
            t.setText("Teste texto");

            //TENTATIVA 3
            Tarefa teste = this.items.get(0);
            teste.url  = "Teste texto";



    public View getView(int position, View convertView, ViewGroup parent) {

        View row = convertView;
        TarefasHolder holder = null;

        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent, false);

        holder = new TarefasHolder();
        holder.tarefa = items.get(position);
        holder.removePaymentButton = (Button)row.findViewById(;

        holder.url = (TextView)row.findViewById(;
        holder.status = (TextView)row.findViewById(;
        holder.lastexecute = (TextView)row.findViewById(;
        holder.connectivity = (TextView)row.findViewById(;
        holder.idle = (TextView)row.findViewById(;
        holder.charging = (TextView)row.findViewById(;
        holder.delay = (TextView)row.findViewById(;




        return row;


    private void setupItem(TarefasHolder holder) {

    public static class TarefasHolder{

        Tarefa tarefa;
        TextView url;
        TextView status;
        TextView lastexecute;
        TextView connectivity;
        TextView delay;
        TextView charging;
        TextView idle;
        Button removePaymentButton;



Those are the attempts I made.


It is not recommended to save the View created in the ListView, you cannot guarantee that this view was destroyed.

If it's a text list, you create a String list and when you want to change the list just change the text of the list, example below:

(Inside the adapter)

List<String> itens;

public void onEvent(MeuEvento me){
    //Sua lógica para saber qual item será alterado
    String s = itens.get(0);
    s = "mudei";
Scroll to Top