专辑艺术不会在自定义simplecursoradpter中显示

时间:2015-07-03 11:19:51

标签: android listview albumart

专辑封面未在自定义simplecursoradpter

中显示

我已成功显示列表视图中的所有专辑名称,但无法显示专辑封面等

虽然每件事情都适用于文字和动画,但专辑封面并没有出现在列表视图中

这是我正在尝试的代码

$entityManager = $this->getEntityManager();
$repository = $entityManager->getRepository('Application\Entity\Usermain');
$emailexists = $repository->findBy(array(
    'userEmail' => $postData['email'],
    'userId!'   => '!'. $postData['id']
));

1 个答案:

答案 0 :(得分:0)

使用此,

    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        if(row==null){
            LayoutInflater inflater=getLayoutInflater();
            row=inflater.inflate(R.layout.itemtexview, parent, false);
        }

        ImageView thumbV = (ImageView)row.findViewById(R.id.thumb);
        TextView textV = (TextView)row.findViewById(R.id.text);

        myCursor.moveToPosition(position);

        String myID = myCursor.getString(myCursor.getColumnIndex(android.provider.MediaStore.Audio.Albums._ID));
        String myData = myCursor.getString(myCursor.getColumnIndex(android.provider.MediaStore.Audio.Albums.ALBUM));
        textV.setText(myData);

        // gets the artWorkUri.
        Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");

// gets the albumArtUri from artWorkUri and albumId.
        Uri albumArtUri = Uri.withAppendedPath(sArtworkUri, myID);
        thumbV.setImageURI(albumArtUri);

        Animation animation = null;
        animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.wave);
        animation.setDuration(200);
        row.startAnimation(animation);
        animation = null;
        return row;
    }