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. Group meetings.

I'm interested in getting together with some other Android devs. Now,
seeing no easy way to set this up on my own, I figured I'd go ahead
and write my info here.  If you're in the area and interested go ahead
and email me or reply to this message here.  Also, if you're
interested in starting your own local meetings go ahead and put your
info in here too.

I live in Utah (SLC area) and with a flexible schedule am available
for a meetup pretty much any time given advance notice. I'm open for
discussions, projects, or even just good debates.  I can host a
barbecue if necessary but it'd probably be a decent trip for anyone
wanting to do that.  Downtown SLC meetings would be great.  Go ahead
and email me ( [EMAIL PROTECTED] )

--~--~---------~--~----~------------~-------~--~----~

2. How did android.R.id.list got into android.R.java file??

Satya, you could not edit R.java manually. This have been generated
automatically by understanding layout files etc.

<ListView android:id="@+id/AAAA".../> is correct. R.id.AAAA comes
from  "android:id="@+id/AAAA"
(the "+" means that Android platform creates automatically the id on
condition that the id does not exsist yet)

AAAA id is displayed in R.java sooner when you wirte @+id.


Satya Komatineni :
--~--~---------~--~----~------------~-------~--~----~

3. Hello World not working

4. error in the Java Runtime Environment

5. App Download Stats

6. Install Android on other HTC phones?

7. Why did I delete the project, but it still run ?