如何获得适配器类的服务?

时间:2019-02-04 01:02:21

标签: android service

我在适配器中使用的充气布局中使用音频,我想在适配器中包括音频管理器服务,以便能够控制音频系统。我没有这样做。 此行代码中的红色下划线顶点

mAudioManager = (AudioManager) ContextCompat.getSystemService(>>>Context<<<,AppCompatActivity.AUDIO_SERVICE);

       public View getView(int position, View convertView, ViewGroup parent) {

        View myView = convertView;
        final IrrVerbeClass myData = getItem(position);

        if (myView == null){
            myView = LayoutInflater.from(getContext()).inflate
                    (R.layout.irregular_verb_card,parent,false);
        }


        TextView tMeaning = (TextView) myView.findViewById(R.id.cMeaning);
        tMeaning.setText(myData.getMeaning());

            mAudioManager = (AudioManager) ContextCompat.getSystemService(Context,AppCompatActivity.AUDIO_SERVICE);
            ImageView tAudioV3 = (ImageView) myView.findViewById(R.id.xAudioV3);
            tAudioV3.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    releaceMediaPlayer();
                    mediaPlayer = MediaPlayer.create(getContext(),myData.getAudio3v());
                    mediaPlayer.start();
                    mediaPlayer.setOnCompletionListener(mOncompletion);
                }
            });
        }
        return myView;

0 个答案:

没有答案