【发布时间】:2011-08-31 14:27:31
【问题描述】:
我在动态列表视图按钮中有查询。我的动态列表视图中有 2 个按钮。我可以看到 onclick 事件和 toast 出现。但是,当我尝试将意图传递给下一个活动时,它不起作用。请告诉我哪里做错了。
我的代码:
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.adaptor_content, null);
// Creates a ViewHolder and store references to the two children
// views
// we want to bind data to.
holder = new ViewHolder();
holder.textLine = (TextView) convertView.findViewById(R.id.textLine);
// holder.iconLine = (ImageView) convertView.findViewById(R.id.iconLine);
holder.buttonLine = (Button) convertView.findViewById(R.id.buttonLine);
holder.DbuttonLine = (Button) convertView.findViewById(R.id.DbuttonLine);
holder.textLine2 =(TextView) convertView.findViewById(R.id.textLine2);
holder.mobile =(TextView) convertView.findViewById(R.id.mobile);
holder.newmes =(TextView) convertView.findViewById(R.id.newmessage);
convertView.setOnClickListener(new OnClickListener() {
private int pos = position;
@Override
public void onClick(View v) {
Toast.makeText(context, "Click-" + String.valueOf(pos), Toast.LENGTH_SHORT).show();
}
});
holder.buttonLine.setOnClickListener(new OnClickListener(){
private int pos = position;
@Override
public void onClick(View v) {
//Toast.makeText(context, "Delete-" + String.valueOf(pos), Toast.LENGTH_SHORT).show();
Intent myIntent = new Intent(v.getContext(), messsagelist.class);
//startActivity(myIntent);
this.startActivityForResult(myIntent, 0);
}
private void startActivityForResult(Intent myIntent, int i) {
// TODO Auto-generated method stub
}
});
holder.DbuttonLine.setOnClickListener(new OnClickListener() {
private int pos = position;
@Override
public void onClick(View v) {
Toast.makeText(context, "Details-" + String.valueOf(pos), Toast.LENGTH_SHORT).show();
}
});
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
【问题讨论】:
标签: android listview button dynamic