简体   繁体   English

android gridview更改项目文本

[英]android gridview change item text

Ive got some gridView and some function which is called when a message arrives from server. 我有一些gridView和一些功能,当消息从服务器到达时会被调用。 In this function I get the values from server and I want to write this value in specific item in the gridView. 在此函数中,我从服务器获取值,并且希望将此值写入gridView的特定项目中。 The problem is I dont have any idea how can I rewrite text of som Item in the gridView and I couldn find any answer on the internet :/ 问题是我不知道如何在gridView中重写som项的文本,而在互联网上找不到任何答案:/

I understand up to some point. 我了解到一定程度。 In my expatiation i think your set by using adapter right. 在我的解释中,我认为您使用adapter的设置正确。 So the simple solution is once you get the new items for a grid. 因此,简单的解决方案是一旦获得网格的新项目。 call the setadapter again. 再次调用setadapter Then that will set the new items. 然后,将设置新项目。 Try it once. 尝试一次。

Actually i have to comment out but i don't have that much points. 实际上,我必须注释掉,但是我没有太多要点。

First you need to to add the received data into arraylist which you used to populate your grid view . 首先,您需要将接收到的数据添加到用于填充网格视图的arraylist中。 You can add the received data into any position of arraylist as you need. 您可以根据需要将接收到的数据添加到arraylist的任何位置。

Then update the Arrayadapter using the following command 然后使用以下命令更新Arrayadapter

   adapter.notifyDataSetChanged();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM