package com.LijslGallery;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import com.LijslGsllery.R;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class ImageGalleryActivity extends Activity {
ListView g;
TextView tv;
ImageView iv;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gallery);
g = (ListView) findViewById(R.id.listview);
g.setAdapter(new ImageAdapter(this));
startLongRunningOperation();
}
protected void startLongRunningOperation() {
Thread getproduct = new Thread() {//worker thread or background thread
public void run() {
SoapObject Soapresponse = Ksoap.CallService(
"GetPhotoAlbum",0,null);
Log.e("soap response", Soapresponse.toString());
try {
if (Soapresponse != null) {
SoapObject Soapresult = (SoapObject) Soapresponse
.getProperty(0);
//Log.e("data", "" + Soapresult.toString());
if (Soapresult != null) {
SoapObject Dataset = (SoapObject) Soapresult
.getProperty(1);
if (Dataset != null) {
SoapObject Table = (SoapObject) Dataset
.getProperty(0);
}
}
}
} catch (NullPointerException f) {
} catch (ClassCastException d) {
} catch (ArrayIndexOutOfBoundsException g) {
}
}
};
getproduct.start();
}
public class ImageAdapter extends BaseAdapter {
public ImageAdapter(Context c) {
mContext = c;
}
public ImageAdapter(OnClickListener onClickListener) {
// TODO Auto-generated constructor stub
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View v;
if ((convertView == null)) {
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.icon1, null);
tv = (TextView) v.findViewById(R.id.icon_text);
iv = (ImageView) v.findViewById(R.id.icon_image);
} else {
v = convertView;
}
tv.setText("position");
iv.setImageResource(mThumbIds[position]);
return v;
}
}
private Context mContext;
Integer[] mThumbIds = new Integer[16];
{
for (int o = 0; o < 16; o++) {
mThumbIds[o] = R.drawable.icon;
}
}
}
note:-internet permission is required for webservice
No comments:
Post a Comment