Hi Rahul,

Some things that I have noticed:

1) You have not initialized the SongsList item in the constructor. in
the constructor have a ArrayList and initialize it with the value that
you have passed (in your case "al").
2) in ur main activity u can use a setListAdapter it is very easy to
use and use the SongsAdapter object in it.
3) You can view Romain Guys video where he talks about how you can
handle list views. Try to use the convertView and only when the
convertView is null only then inflate and inflation is very expensive.
4) in ur getView you are using variable i - you can directly use
"position" for accessing.


What I would recommend is just try a simple listAdapter with text
views instead of displaying images as well and once that is done you
can add ur code for images.

Thanks,
Prajakta


On Apr 20, 6:06 am, Rahul <rahulvarma.kalidindi0...@gmail.com> wrote:
> Hi, I am trying to display thelistof songs using array adapters. But
> the problem is i couldnt display thelistand only empty screen with
> preset background is showing up. Here's the code...All the thee are
> seperate classes... Plz help me...
>
> public class SongsAdapter extends ArrayAdapter<SongsList>{
>         private Context context;
>         TextView tvTitle;
>         TextView tvMovie;
>         TextView tvSinger;
>         String s;
>         Intent myintent = new Intent();
>
>         public SongsAdapter(Context context, int resource,
>                         int textViewResourceId, ArrayList<String> al) {
>                         super(context, resource, textViewResourceId);
>                         this.context=context;
>
>                 }
>
>         public View getView(int position, View convertView, ViewGroup parent)
> {
>                 final int i=position;
>
>                List<SongsList> listSongs = new ArrayList<SongsList>();
>                 String title = listSongs.get(i).gettitleName().toString();
>                 String album = listSongs.get(i).getmovieName().toString();
>                 String artist = listSongs.get(i).getsingerName().toString();
>                 String imgal = listSongs.get(i).gettitleName().toString();
>
>                 myintent.getStringArrayListExtra(title);
>                 myintent.getStringArrayListExtra(album);
>                 myintent.getStringArrayListExtra(artist);
>                 myintent.getStringArrayListExtra(imgal);
>
>                 LayoutInflater inflater = ((Activity) 
> context).getLayoutInflater();
>                 View v = inflater.inflate(R.layout.row, null);
>         tvTitle=(TextView)v.findViewById(R.id.text2);
>         tvMovie=(TextView)v.findViewById(R.id.text3);
>         tvSinger=(TextView)v.findViewById(R.id.text1);
>         tvTitle.setText(title);
>                 tvMovie.setText(album);
>         tvSinger.setText(artist);
>
>         final ImageView im=(ImageView)v.findViewById(R.id.image);
>             s="http://www.gorinka.com/"+imgal;
>              String imgPath=s;
>             AsyncImageLoaderv asyncImageLoaderv=new
> AsyncImageLoaderv();
>             Bitmap cachedImage =
> asyncImageLoaderv.loadDrawable(imgPath, new
> AsyncImageLoaderv.ImageCallback() {
>                     public void imageLoaded(Bitmap imageDrawable, String
> imageUrl) {
>
>                         im.setImageBitmap(imageDrawable);
>                    }
>               });
>              im.setImageBitmap(cachedImage);
>
>            return v;
>
>         }
>
>          public class imageloader implements Runnable{
>
>                 private String ss;
>                         private ImageView im;
>
>                  public imageloader(String s,  ImageView im) {
>                          this.ss=s;
>                          this.im=im;
>                          Thread thread = new Thread(this);
>                      thread.start();
>                             }
>                         public void run(){
>                      try {
>
>                          HttpGet httpRequest = null;
>                                      httpRequest = new HttpGet(ss);
>                                      HttpClient httpclient = new 
> DefaultHttpClient();
>                                      HttpResponse response = (HttpResponse)
> httpclient.execute(httpRequest);
>                                      HttpEntity entity = response.getEntity();
>                                      BufferedHttpEntity bufHttpEntity = new
> BufferedHttpEntity(entity);
>                          InputStream is = bufHttpEntity.getContent();
>
>                          Bitmap bm = BitmapFactory.decodeStream(is);
>                          Log.d("img","img");
>
>                          is.close();
>                          im.setImageBitmap(bm);
>
>                      } catch (Exception t) {
>                                 Log.e("bitmap url", "Exception in 
> updateStatus()", t);
>
>                         }
>
>              }
>          }
>
> }
>
> public SongsList(String titleName, String movieName, String
> singerName,String imagePath,String mediaPath ) {
>                 super();
>                 this.titleName = titleName;
>                 this.movieName = movieName;
>                 this.singerName = singerName;
>                 this.imagePath = imagePath;
>                 this.mediaPath = mediaPath;
>         }
>
>     public String gettitleName()
>     {
>         return titleName;
>     }
>     public void settitleName(String titleName) {
>         this.titleName = titleName;
>     }
>     public String getmovieName()
>     {
>         return movieName;
>     }
>     public void setmovieName(String movieName) {
>         this.movieName = movieName;
>     }
>     public String getsingerName()
>     {
>         return singerName;
>     }
>     public void setsingerName(String singerName) {
>         this.singerName = singerName;
>     }
>     public String getimagePath()
>     {
>         return imagePath;
>     }
>     public void setimagePath(String imagePath) {
>         this.imagePath = imagePath;
>     }
>     public String getmediaPath()
>     {
>         return mediaPath;
>     }
>     public void setmediaPath(String mediaPath) {
>         this.mediaPath = mediaPath;
>     }
>
> }
>
> public class MusicListActivity extends Activity {
>         ArrayList<String> al=new ArrayList<String>();
>         //ArrayList<String> al=new ArrayList<String>();
>         ArrayList<String> node=new ArrayList<String>();
>         ArrayList<String> filepath=new ArrayList<String>();
>         ArrayList<String> imgal=new ArrayList<String>();
>         ArrayList<String> album=new ArrayList<String>();
>         ArrayList<String> artist=new ArrayList<String>();
>
>         @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.openadiuofile)
>         ListViewlist= (ListView)findViewById(R.id.list1);
>         al=getIntent().getStringArrayListExtra("titles");
>                 //node=getIntent().getStringArrayListExtra("nodeid");
>                 filepath=getIntent().getStringArrayListExtra("apath");
>                 imgal=getIntent().getStringArrayListExtra("imgpath");
>                 album=getIntent().getStringArrayListExtra("album");
>                 artist=getIntent().getStringArrayListExtra("artist");
>         SongsAdapter adapter = new SongsAdapter(this,R.layout.row,
> R.id.text2,null);
>        list.setAdapter(adapter);
>         Toast.makeText(this, "ListDisplayed",
> Toast.LENGTH_SHORT).show();
>         }
>
> }
>
> It will be very helpful if i can know what the bugs are and also the
> the way to implement it. Some code snippets or sample code to
> implement will be very helpful... Thanks in advance...
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to