I am new developer in android. I am working with soap object in my application for communicate with the .net db services.I am getting response as strings from DB server. But my intention is when I get a string from db server as response then imediatly view as text view similarly I am getting images encoded string.how to get response imedialty as view. I have written code as follows:
String xml="<spGetUserMessages><SearchLocation></SearchLocation><LoginUserID>"+Userid+"</LoginUserID></spGetUserMessages>";
I am sending request as XML to db server
The response from db server is in list:
List<MessageClass> response=new ParseXml().getUserMessages(new Generic().getMessages(xml));
String messages=new String[response.size()];
for(int i=0;i<response.size();i++)
{
//the response values are saved in messages array
messages[i]=response.get(i).getmessage();
}
I have written a base adapter class in that class we have a method as getView I have implemented as follows:
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.item, null);
TextView text=(TextView)vi.findViewById(R.id.text);;
ImageView image=(ImageView)vi.findViewById(R.id.image);
Log.v("rrrrrrrrrr", "rrrrrrrr"+messages[position]);
text.setText(messages[position]);
}
From the above code I am displaying all messages at a time. But in this situation the response is taking time then I am getting blank screen. Here my intention is when I get a string response then I will view that string as text view next time next similarly untill reposnse size has completed.
What you can do is display the Listview without waiting for response and from background thread add the responses to messages
and call
mAdapter.notifyDatasetChanged();
This is concept of LazyLoading
and I hope it should work
Update
runOnUiThread(new Runnable() {
public void run() {
adapter.notifyDataSetChanged();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With