gpt4 book ai didi

android - 从原始文件夹播放声音,与 ListView 的每一行成比例

转载 作者:行者123 更新时间:2023-12-03 02:12:39 24 4
gpt4 key购买 nike

我想在以下代码中与列表的每一行成比例地播放原始文件夹中的声音文件,其意思是例如用lorem播放1.mp3,用ipsum和2.mp3播放...

我应该在代码中添加什么?

请帮我...

我的代码:

    public class InflatList extends ListActivity {
private TextView selection;
private static final String[] items = {"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "morbi", "vel", "ligula", "vitae", "arcu", "placerat", "ante", "porttitor", "sodales", "pellentesque", "augue", "purus"};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

setListAdapter(new IconicAdapter());
selection = (TextView)findViewById(R.id.selection);
}

//=====================
//New Class Starts Here
//=====================
class IconicAdapter extends ArrayAdapter<String> {

public IconicAdapter() {
super(InflatList.this, R.layout.row, items);
}

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

TextView label = (TextView)row.findViewById(R.id.label);
label.setText(items[position]);
ImageView icon = (ImageView)row.findViewById(R.id.pic);
ImageButton btnplay = (ImageButton)row.findViewById(R.id.btnplay);

return(row);
}
}
}

最佳答案

假设您已经尽早播放了声音

因此,您可以从onListItemClick上的获得关注

 @Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);

// find which item clicked from the id,

//Place your code here for play video




}

关于android - 从原始文件夹播放声音,与 ListView 的每一行成比例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22780158/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com