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. getHostByName failing

My application tries to open a socket to a remote (ie. out on the
internet) server but fails with an "Unknown host" exception.  I've
simplified the code and plugged it into HelloAndroid as follows:

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        try {
        openSocket("www.google.com", 80);
        } catch (IOException e) {
        e.printStackTrace();
        }
    }

    private Socket sock;

    private void openSocket(String host, int port) throws IOException
{
        InetAddress inet = InetAddress.getByName(host);  // exception
raised here
        sock = new Socket();
        sock.connect(new InetSocketAddress(inet, port), 3000);
    }

}

As the emulator's web browser can connect to www.google.com
successfully I assume my network configuration is correct.  I even
disabled the firewall on my development machine but to no avail.

BTW my application will connect to a different server and port - I'm
just using google.com & 80 as an example.

All help appreciated.

richard.

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

2. reg porting android on target pxa270 arm based board

Dear all
            im new to android...i ve downloaded the android
kernel-2.6.25 and ported successfully on a pxa 270 arm based platform.
Now got the android file system images (system.tar.gz and data.tar.gz)
from a link..can some body help me out to port this file system in my
arm based board..also i need to know how to run android applications on
a pxa 270 processor using dalvik..

thanks in advance..

regards
krithika
e-consystems

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

3. Mail api or access to mail authentication?

4. DL Android

5. MapView showing GPS positions incorrect

6. Contacts.PresenceColumns documentation/API mismatch.

7. Question regarding default Contacts application.