problem displaying music list using custom adapters

by Rahul » Wed, 21 Apr 2010 02:30:33 GMT


Sponsored Links
 i, I am trying to display the list of songs using array adapters. But
the problem is i couldnt display the list and 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();



problem displaying music list using custom adapters

by Rahul » Thu, 22 Apr 2010 12:34:44 GMT


  have tried to implement the above by using the following code...
But, this too is showing the same...


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{
Log.d("webObjectList","webObjectList");
getsongs();

} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XMLRPCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
Log.e("mee","process over");
}

@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();

}

public void webObjectList(Object[] songListObj,String logInSess)
throws XMLRPCException{
songNodeWeb = new HashMap<?,?>[songListObj.length];


for(int i=0;i<songListObj.length;i++){ //imgListObj.length
songNodeWeb[i]=(HashMap<?,?>)songListObj[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<?,?> 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("field_image");
HashMap<?,?>[] songDetails=new
HashMap<?,?>[songObject.length];
songDetails[0]=(HashMap<?, ?>)songObject[0];
String path=(String) songDetails[0].g


Sponsored Links


problem displaying music list using custom adapters

by praj » Thu, 22 Apr 2010 13:13:12 GMT


 i 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:06am, Rahul <rahulvarma.kalidindi0...@gmail.com> wrote:
>



Other Threads

1. Book for learning Android

Hii all,

Can anyone suggest me good book for learning android? And if u have copy of
it then do e-mail me.

-- 
Warm Regards,
Chirayu Dalwadi

Email: chirayu.dalw...@gmail.com

--

2. Cannot execute SDK Setup.exe

Hello,

I'm having strange problems doing my first steps with my android
phone.
First i'm having heavy trouble installing the Android SDK (android-
sdk_r3-windows.zip).
The SDK Setup.exe file refuses to execute. It just spawns a rectangle
and vanishes. I-ve tried running it with administrator privileges,
compatibility mode etc... nothing.
Ive also re/downloading the zip and re/extracted it and the problem
persists.
Running it on the shell just does nothing too. Not even an error
message. Zero.
Im also running Windows 7 64bit with latest patches.
My pc is a desktop AMD athlon X2 CPU, 4GB RAM. I-ve tried running on a
XP SP3 box and it executed fine.
Any ideas... thanks on advance.

Tiago Lopes

P.S. why is my keyboard layout changed when writing this post_

-- 

3. Setting activity in tab content

4. Example sync adapter?

5. Adding an ArrayList of LinearLayout objects to the UI

6. How to handle fling motion for multiple views on homescreen

7. OpenGL Fillrate Issues