Saturday, April 2, 2011

Android UI Components


public class ListView extends ListActivity
{


        private ArrayList<FeildSetterGetterClass> m_feildsettergetter = null;
private FeildSetterGetterAdapter m_adapter;

public void onCreate(Bundle bundle)
{
super.onCreate(bundle);
this.setContentView(R.layout.listview);

m_InboxItemDetailss = new ArrayList<InboxItemDetails>();

this.m_adapter = new FeildSetterGetterAdapter (this, R.layout.inboxrows,
m_feildsettergetter );
setListAdapter(this.m_adapter);
getItemDetails();
ListView listView = getListView();



}


private void getItemDetails() 
{

try {
m_InboxItemDetailss = new ArrayList<FeildSetterGetterClass>();

for (int i = 0; i < nextPageInboxVideos.size(); i++)
                      {

Hashtable hashtable = (Hashtable) nextPageInboxVideos
.elementAt(i);
String time = (String) hashtable.get("time");
String targetleaf = (String) hashtable.get("targetleaf");
String summary = (String) hashtable.get("summary");
String imageName = (String) hashtable.get("image");
String name = (String) hashtable.get("name");
String title = (String) hashtable.get("title");
InboxItemDetails o1 = new InboxItemDetails();
o1.setDate(time);
o1.setIcon(imageName);
o1.setMailSummary(summary);
o1.setMailTitle(title);
o1.setName(name);
o1.setTargetLeaf(targetleaf);
m_InboxItemDetailss.add(o1);

}


} catch (Exception e) {
Log.e("BACKGROUND_PROC", e.getMessage());
}
returnRes();
}



private void returnRes() {

if (m_feildsettergetter != null && m_feildsettergetter .size() > 0) {
m_adapter.notifyDataSetChanged();
for (int i = 0; i < m_feildsettergetter .size(); i++)
m_adapter.add(m_feildsettergetter .get(i));
}

m_adapter.notifyDataSetChanged();


}





Wednesday, January 26, 2011

Serialize byte array using ksoap android

Hi Guys,
Ksoap does not implement serialization itself while sending byte array using ksoap call.
When we are using web services in android we need to implement serialization before we send the byte array otherwise we are getting error can not serialize byte array.

    private static final String NAMESPACE = ".xsd url taken from  the web service URL";
    private static final String URL = "web service URL";
    private static final String SOAP_ACTION = "Action port typr";
    private static final String METHOD_NAME = "Method name";
the above parameter can be taken from the users web service (?WSDL) url

SoapObject request = new SoapObject(NAMESPACE, AUTH_METHOD);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
 
 
new MarshalBase64().register(envelope);   //serialization
envelope.encodingStyle = SoapEnvelope.ENC;

       
        request.addProperty("body", str);
        request.addProperty("image", imagebyte);
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try{
        androidHttpTransport.call(SOAP_ACTION, envelope);
           
            SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
           
            String str=resultsRequestSOAP.toString();
           
   }catch(Exception e)
{
}