Hi,
I have the following errors when i try to access the simple adapter from my program...
Plz can anyone help me solving the error... Desperate to get it done....
android.widget.SimpleAdapter.getCount(SimpleAdapter.java:95) android.widget.ListView.setAdapter(ListView.java:431) com.stellent.gorinka.MusicListActivity.list(MusicListActivity.java:76) com.stellent.gorinka.MusicListActivity$1.run(MusicListActivity.java:67) android.os.Handler.handleCallback(Handler.java:587) android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:123) android.os.Handler.handleCallback(Handler.java:587) android.os.Handler.dispatchMessage(Handler.java:92) android.os.Looper.loop(Looper.java:123)
Here' the code for Adapter...
public class SongsAdapter extends SimpleAdapter{
static List<HashMap<String,String>> songsList;
Context context;
LayoutInflater inflater;
public SongsAdapter(Context context,List<HashMap<String,String>> imgListWeb,int layout,String[] from,int[] to,LayoutInflater inflater) {
super(context,songsList,layout,from,to);
this.songsList=songsList;
this.context=context;
this.inflater=inflater;
// TODO Auto-generated constructor stub
}@Override
public View getView(int postition,View convertView,ViewGroup parent)throws java.lang.OutOfMemoryError{
try {
View v = ((LayoutInflater) inflater).inflate(R.layout.row,null);
ImageView images=(ImageView)v.findViewById(R.id.image);
TextView tvTitle=(TextView)v.findViewById(R.id.text1);
TextView tvAlbum=(TextView)v.findViewById(R.id.text2);
TextView tvArtist=(TextView)v.findViewById(R.id.text3);
HashMap<String,String> songsHash=songsList.get(postition);
String path=songsHash.get("path");
String title=songsHash.get("title");
String album=songsHash.get("album");
String artist=songsHash.get("artist");
String imgPath=path;
final ImageView imageView = (ImageView) v.findViewById(R.id.image);
AsyncImageLoaderv asyncImageLoader=new AsyncImageLoaderv();
Bitmap cachedImage = asyncImageLoader.loadDrawable(imgPath, new AsyncImageLoaderv.ImageCallback() {
public void imageLoaded(Bitmap imageDrawable, String imageUrl) {
imageView.setImageBitmap(imageDrawable);
}
});
imageView.setImageBitmap(cachedImage);
tvTitle.setText(title);
tvAlbum.setText(album);
tvArtist.setText(artist);
return v;
}
catch(Exception e){
Log.e("error",e.toString());
}
return null;
}
And also in my main program the focus is not entering the loop... The implementation in the loop isnt getting executed...Here's the code for it...
public void list()
{ Log.d("#####","#####");
LayoutInflater inflater=getLayoutInflater();
String[] from={};
int[] n={};
adapter=new SongsAdapter(getApplicationContext(),songNodeDet,R.layout.row,from,n,inflater);
lv.setAdapter(adapter);}
private Handler handler = new Handler() {
public void handleMessage(Message msg){
Log.d("*****","handler");
removeDialog(0);
p.dismiss();
}
}; public void webObjectList(Object[] imgListObj,String logInSess) throws XMLRPCException{
songNodeWeb = new HashMap<?,?>[imgListObj.length];
if(imgListObj!=null){
Log.e("completed","completed");
for(int i=0;i<imgListObj.length;i++){ //imgListObj.length
songNodeWeb[i]=(HashMap<?,?>)imgListObj[i];
String nodeid=(String) songNodeWeb[i].get("nid");
Log.e("img",i+"completed");
HashMap<String,String> nData=new HashMap<String,String>();
nData.put("nid",nodeid);
Object nodeget=client.call("node.get",logInSess,nodeid);
HashMap<?,?> imgNode=(HashMap<?,?>)nodeget;
String titleName=(String) imgNode.get("titles");
String movieName=(String) imgNode.get("album");
String singerName=(String) imgNode.get("artist");
nData.put("titles", titleName);
nData.put("album", movieName);
nData.put("artist", singerName);
Object[] imgObject=(Object[])imgNode.get("title_format");
HashMap<?,?>[] imgDetails=new HashMap<?,?>[imgObject.length];
imgDetails[0]=(HashMap<?, ?>)imgObject[0];
String path=(String) imgDetails[0].get("filepath");
if(path.contains(" ")){
path=path.replace(" ", "%20");
}
String imgPath="http://www.gorinka.com/"+path;
paths.add(imgPath);
nData.put("path", imgPath);
Log.e("my path",path);
String mime=(String)imgDetails[0].get("filemime");
nData.put("mime", mime);
SongsList songs=new SongsList(titleName,movieName,singerName,imgPath,imgPath);
SngList.add(i,songs);
songNodeDet.add(i,nData);
}
Log.e("paths values",paths.toString());
// return imgNodeDet;
handler.sendEmptyMessage(0);
}
}
public void getSongs() throws MalformedURLException, XMLRPCException
{
String ur="http://www.gorinka.com/?q=services/xmlrpc";
URL u=new URL(ur);
client = new XMLRPCClient(u);
//Connecting to the website
HashMap<?, ?> siteConn =(HashMap<?, ?>) client.call("system.connect");
// Getting initial sessio id
String initSess=(String)siteConn.get("sessid");
//Login to the site using session id
HashMap<?, ?> logInConn =(HashMap<?, ?>) client.call("user.login",initSess,"prakash","stellentsoft2009");
//Getting Login sessid
logInSess=(String)logInConn.get("sessid");
websongListObject =(Object[]) client.call("nodetype.get",logInSess,"");
webObjectList(websongListObject,logInSess);
Log.d("webObjectList","webObjectList");
runOnUiThread(returnRes);
}
}