Reputation: 7536
Hi I am developing android application in which I am using grid view. I want to updated grid item dynamically.My grid item contains one title text. I tried to do it like this but it is not working for me.
((Activity)context).runOnUiThread(new Runnable()
{
public void run()
{
Debug.print("this is update progress inside thread ...");
owner.setText("Uploading...");
invalidate();
requestLayout();
}
});
So in above code its printing debug statement. But not updating my owner text which is inside grid item.
I tried this also...
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
owner.setText("Uploading...");
}
};
handler.sendEmptyMessage(0);
Upvotes: 1
Views: 2163
Reputation: 52494
Check if you have any Thread.sleep() in your code that might be blocking the UI.
Upvotes: 0
Reputation: 691
runOnUiThread(new Runnable() {
@Override
public void run() {
Debug.print("Updating UI ...");
owner.setText("Uploading ...");
invalidate();
requestLayout();
}
});
Upvotes: 0
Reputation: 545
So in above code its printing debug statement. But not updating my owner text which is inside grid item.
I think it's textview does not reference to your item in grid adapter. You can check it by set tag when init and getTag() inside runonUIThread method.
Let check this textview is local or global variable. If global, it's only reference to the last item - then check the last item change? OK if it's not. Let post full ur code.
Upvotes: 0
Reputation: 4661
Try to refresh your adapter which you used to load the grid item. Either you could use invalidateViews() method or adapter.notifyDataSetChanged()
This will help you to resolve your issue.
Happy coding..
Upvotes: 0