Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8768869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:10:47+00:00 2026-06-13T17:10:47+00:00

I want to update a textview present in my project to be updated after

  • 0

I want to update a textview present in my project to be updated after a fixed time and want to show the changes on the screen/ui.As per debugging,the value of the textview is changing but the changes are not getting visible on the screen/ui.These are the xmls:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:id="@+id/wrapper"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/comment"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_margin="5dip"
            android:background="@drawable/bubble_yellow"
            android:paddingLeft="10dip"
            android:text="Hello bubbles!"
            android:textColor="@android:color/primary_text_light" />
    </LinearLayout>

</LinearLayout>

This one is the other xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

 <include
        layout="@layout/listitem_discuss" />

    <ListView
        android:id="@+id/listView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" >
    </ListView>

</RelativeLayout>

This is the main class:

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_discuss);
        random = new Random();
        ipsum = new LoremIpsum();

        lv = (ListView) findViewById(R.id.listView1);

        adapter = new DiscussArrayAdapter(getApplicationContext(), R.layout.listitem_discuss);

        lv.setAdapter(adapter);

        tv = (TextView)this.findViewById(R.id.comment);
        ll = (LinearLayout)findViewById(R.id.wrapper);

        addItems();
        ReduceTimeIteration();
    }

    public void ReduceTimeIteration() // checks after 2 minutes for any message to delete
    {

        try
        {
            final Handler m_handler = new Handler();
            m_handlerTask = new Runnable()
            {
                @Override 
                public void run() 
                {
                    String a = tv.getText().toString();
                    if(tv.getText() == "Hello bubbles!")
                    {
                                                   tv.setText("hi");                            
                    }
                    else{
                        tv.setText("hello");  // postInvalidate()
                        adapter.notifyDataSetChanged(); 
                    }
                    m_handler.postDelayed(m_handlerTask, 2000); 
                }
            };
            m_handlerTask.run();
        }
        catch(Exception e)
        {

        }
    }
    private String addItems() {
        String a = "Hello bubbles";
        adapter.add(new OneComment(true,a));
        return a;
    }

}

This the array adapter class:

public class DiscussArrayAdapter extends ArrayAdapter<OneComment> {

    private TextView countryName;
    private List<OneComment> countries = new ArrayList<OneComment>();
    private LinearLayout wrapper;

    @Override
    public void add(OneComment object) {
        countries.add(object);
        super.add(object);
    }

    public DiscussArrayAdapter(Context context, int textViewResourceId) {
        super(context, textViewResourceId);
    }

    public int getCount() {
        return this.countries.size();
    }

    public OneComment getItem(int index) {
        return this.countries.get(index);
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        if (row == null) {
            LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            row = inflater.inflate(R.layout.listitem_discuss, parent, false);
        }

        wrapper = (LinearLayout) row.findViewById(R.id.wrapper);

        OneComment coment = getItem(position);

        countryName = (TextView) row.findViewById(R.id.comment);

        countryName.setText(coment.comment);

        countryName.setBackgroundResource(coment.left ? R.drawable.bubble_yellow : R.drawable.bubble_green);
        wrapper.setGravity(coment.left ? Gravity.LEFT : Gravity.RIGHT);

        return row;
    }

    public Bitmap decodeToBitmap(byte[] decodedByte) {
        return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
    }

}

This is the class through which i am passing data into adapter:

public class OneComment {
    public boolean left;
    public String comment;

    public OneComment(boolean left, String comment) {
        super();
        this.left = left;
        this.comment = comment;
    }
}

In this project,i want to update the value of textview tv in the main class.The value is changing actually,but not getting visible on the screen/ui.Please help me.Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:10:48+00:00Added an answer on June 13, 2026 at 5:10 pm

    try change this method

    private String addItems() {
            String a = "Hello bubbles";
            adapter.add(new OneComment(true,a));
            return a;
        }
    

    to

    private String addItems() {
            String a = "Hello bubbles";
    
            adapter.notifyDataSetChanged();
    
            adapter.add(new OneComment(true,a));
    
            adapter.notifyDataSetInvalidated();
    
            return a;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guess that I have a TextView that I want to update it in some
I want to update my PHP GUI view when my data source is updated(data
I want to update the lastlogin column value .i wrote the code like this
I'm currently developing an android application. It needs to update a textview value periodically.
I have a textViewController class. I want to set(basically update) the corresponding textView's content
I want to have a portion of my TextView invisible. In detail, I present
I want to extract a JSON string from a database and update a textview.My
i want update textarea content onclock on a input button for example: <input type=button
What I want: Update all new commits from server with my local repository in
i have ios application with xcdatamodeld, i want update some data so need a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.