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. Changing default theme for OEMs and Android compatibility

The only assumption with the default theme in the SDK is that light
text on a dark background.  However, will an OEM jeopardize being
Android compatible if they change the default theme to be dark text on
a light background?

The reason for this is that I don't want all the built-in applications
to have to specify some custom theme since it's easier to just change
the default theme.  Also, I would like those 3rd party applications
that use the default theme to change as well so there is consistency
throughout the device.
--~--~---------~--~----~------------~-------~--~----~

2. MediaPlayer plays sound but screen is black





Oh, right, of course. My original comment stands then :)
You'll have to use "new MediaPlayer" instead of the MediaPlayer.create
convenience method.

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

3. Loosing ability to find view by id after orientation change

4. Map not displayed due to "Maps_Persistence" error

5. Question about defining selector drawable

6. RTSP and MMS - mediaplayer shenanigans

7. WebView.addJavascriptInterface - only String and void supported from Java to Javascript?