我想从 onclicklistener 更改 imageview 源(当然还有音乐)。它已更改,但每次单击时第一张图像都会更改。我该如何解决?
这是我的代码:
public View getView(final int p, View v, ViewGroup arg2)
{
Log.w("BaseAdapter", "p: "+p+", preP: "+preP );
if (v == null)
v = li.inflate(R.layout.listview_item, null);
ImageView iv = (ImageView) v.findViewById(R.id.imageView1);
TextView baslik = (TextView) v.findViewById(R.id.textView1);
baslik.setText( isimler[p] );
if ( p == preP )
iv.setImageResource(R.drawable.stop);
v.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
if( preP != p )
{
System.out.println("müzik çalışılacak.");
mPlay = MediaPlayer.create( getApplicationContext(), sarkilar[p] );
mPlay.start();
preP=p;
}
else
{
mPlay.stop();
preP=-1;
}
//getView(p, v, arg2);
initList();
}
});
return v;
}