Hi! Just took a really quick look but AFAICT you try to start the runnable r from getSongs() but getSongs() is only called from the runnable r, hence a moment 22. So you probably have to start the runnable r from onCreate()/onStart() as well (however AFAICT you gonna end up in a loop calling getSongs() over and over again). But as I said I only took a really quick look and might have overlooked something....
/Erik On Apr 22, 12:58 pm, Rahul <[email protected]> wrote: > Hi i have a problem accessing run() method in my program. The rum > method is not getting focus at all. The Log message that is present > outside the loop is getting displayed and i am getting a blank screen > with preset background.Here's the code... > > public class MusicListActivity extends Activity { > List<HashMap<String, String>> songNodeDet = new > ArrayList<HashMap<String,String>>(); > HashMap<?,?>[] songNodeWeb; > XMLRPCClient client; > String logInSess; > ArrayList<String> paths=new ArrayList<String>(); > public ListAdapter adapter ; > Object[] websongListObject; > List<SongsList> SongsList=new ArrayList<SongsList>(); > Runnable r; > ProgressDialog p; > ListView lv; > > @Override > public void onCreate(Bundle si){ > super.onCreate(si); > > setContentView(R.layout.openadiuofile); > lv=(ListView)findViewById(R.id.list1); > r=new Runnable(){ > > public void run(){ > try{ > > getSongs(); > list(); > Log.d("handler","handler"); > removeDialog(0); > p.dismiss(); > > } catch (MalformedURLException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (XMLRPCException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > }; > Log.e("***","process over"); > > } > > @Override > protected void onResume() { > // TODO Auto-generated method stub > super.onResume(); > > } > > public void webObjectList(Object[] songListObj) throws > XMLRPCException{ > songNodeWeb = new HashMap<?,?>[songListObj.length]; > > for(int i=0;i<songListObj.length;i++){ > songNodeWeb[i]=(HashMap<?,?>)songListObj[i]; > String nodeid=(String) songNodeWeb[i].get("nid"); > > Log.e("Song",i+"completed"); > HashMap<String,String> nData=new HashMap<String,String>(); > nData.put("nid",nodeid); > Object nodeget=client.call("node.get",nodeid); > HashMap<?,?> songNode=(HashMap<?,?>)nodeget; > String title=(String) songNode.get("title"); > String album=(String) songNode.get("album"); > String artist=(String) songNode.get("artist"); > > nData.put("title", title); > nData.put("album", album); > nData.put("artist", artist); > > Object[] songObject=(Object[])songNode.get("title_format"); > HashMap<?,?>[] songDetails=new HashMap<?,?>[songObject.length]; > > songDetails[0]=(HashMap<?, ?>)songObject[0]; > String path=(String) songDetails[0].get("filepath"); > > if(path.contains(" ")){ > path=path.replace(" ", "%20"); > } > > String songPath="http://www.gorinka.com/"+path; > paths.add(songPath); > nData.put("path", songPath); > Log.e("my path",path); > SongsList songsList=new SongsList(title, album, > artist,songPath,songPath); > SongsList.add(i,songsList); > songNodeDet.add(i,nData); > } > > Log.e("paths values",paths.toString()); > handler.sendEmptyMessage(0); > > } > > 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); > } > > public void getSongs() throws MalformedURLException, XMLRPCException > { > String ur="http://www.gorinka.com/"; > URL u=new URL(ur); > client = new XMLRPCClient(u); > websongListObject =(Object[]) > client.call("nodetype.get","titles"); > webObjectList(websongListObject); > Log.d("webObjectList","webObjectList"); > runOnUiThread(r);} > > private Handler handler = new Handler() { > public void handleMessage(Message msg){ > Log.d("handler","handler"); > removeDialog(0); > p.dismiss(); > } > > }; > } > > I m trying to access the strings through simple adapter... Here's 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;} > > public static Bitmap loadImageFromUrl(String url) { > InputStream inputStream;Bitmap b; > try { > inputStream = (InputStream) new URL(url).getContent(); > BitmapFactory.Options bpo= new BitmapFactory.Options(); > bpo.inSampleSize=2; > b=BitmapFactory.decodeStream(inputStream, null,bpo ); > return b;} catch (IOException e) { > > throw new RuntimeException(e); > } > > } > > Plz help me determinre the problem and solution for my problem... Need > it badly... > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

