I have a list listview in my code that contains 2 buttons and 2 TextViews. I want to access the text of each textView by Clicking on buttons. here is the code of the adapter...

public class TracksAdapter extends SimpleAdapter {
    public TracksAdapter(Context context, List<? extends Map<String, ?>> data, int      resource, String[] from, int[] to) {
        super(context, data, resource, from, to);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final TracksAdapter proxy = this;
        final View trackView = super.getView(position, convertView, parent);

        Button dl = (Button) trackView.findViewById(R.id.dl);
        dl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // Do something with data : proxy.getItem(position)
                TextView tv = (TextView) trackView.findViewById(R.id.track);
                String track = tv.getText().toString();
                Toast.makeText(getApplicationContext() , track , Toast.LENGTH_LONG);
            }
        });

        Button play = (Button) trackView.findViewById(R.id.play);
        play.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // Do something with data : proxy.getItem(position)
                Toast.makeText(getApplicationContext() , String.valueOf(proxy.getItem(position)).indexOf("file=") , Toast.LENGTH_LONG);
            }
        });

        return trackView;
    }
}

the result of proxy.getItem(position) is something like {id=4 , name=foo , track=fofoo}

what should I do to access 'foo' ????

Related posts

Recent Viewed