How to display db string response as one on one in Android?

I am a new developer in Android. I work with a soap object in my application to communicate with .net db services. I get the answer as strings from the database server. But my intention is that when I get the string from the db server as an answer, then imediatly treats it as a text view, so that I get the images encoded by string.how to get the imedialty response as view. I wrote the code as follows:

String xml="<spGetUserMessages><SearchLocation></SearchLocation><LoginUserID>"+Userid+"</LoginUserID></spGetUserMessages>"; 

I am sending the request as XML to the db server

The db server response in the 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 wrote a base adapter class in this class, we have a method like getView, which I 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]);
    }

. , . , , , .

+5
2

, Listview, , messages

mAdapter.notifyDatasetChanged();

LazyLoading, ,

runOnUiThread(new Runnable() {
public void run() {
    adapter.notifyDataSetChanged();
}
});
+1

AsyncTask , ,

private String messages[];
class BackgroundTask extends AsyncTask<Void, Void, Void>{

     public void doInBackground(Void... arg){

      List<MessageClass> response=new ParseXml().getUserMessages(new Generic().getMessages(xml));

        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();

        } 
     }

     public void postExecute(Void result){
           // here you initialize the listview so the getview() method will call after fetching the response and store into the array.
     }
}
+1

All Articles