android中如何实现在自定义的listview中点击一个按钮一个对应的进度条加载?求高手解答
2个回答
2012-04-23
展开全部
private class Adatpter extends BaseAdapter{
@Override
public int getCount() {
return 5;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = getLayoutInflater().inflate(R.layout.test_list_try_item, null);
Button btn = (Button) view.findViewById(R.id.test_list_try_item_button);
btn.setOnClickListener(new OnBtnClickListener((ProgressBar) view.findViewById(R.id.test_list_try_item_progressbar)));
return view;
}
}
private class OnBtnClickListener implements OnClickListener{
private int progress = 0;
private ProgressBar bar = null;
public OnBtnClickListener(ProgressBar bar){
this.bar = bar;
}
@Override
public void onClick(View v) {
if(null != bar)
bar.setProgress(progress);
progress = (progress + 10)%100;
}
}
不知道你要的是不是这样的效果。随便写的,能用,希望能帮到你
@Override
public int getCount() {
return 5;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = getLayoutInflater().inflate(R.layout.test_list_try_item, null);
Button btn = (Button) view.findViewById(R.id.test_list_try_item_button);
btn.setOnClickListener(new OnBtnClickListener((ProgressBar) view.findViewById(R.id.test_list_try_item_progressbar)));
return view;
}
}
private class OnBtnClickListener implements OnClickListener{
private int progress = 0;
private ProgressBar bar = null;
public OnBtnClickListener(ProgressBar bar){
this.bar = bar;
}
@Override
public void onClick(View v) {
if(null != bar)
bar.setProgress(progress);
progress = (progress + 10)%100;
}
}
不知道你要的是不是这样的效果。随便写的,能用,希望能帮到你
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询