Hi我得到了一个自定义列表视图,并试图启动一个新的按钮点击活动,但是当我尝试设置一个意图时发生,我想这是因为我的自定义数组类没有扩展活动。这些按钮触发警报设置。有什么办法可以让我有意在这堂课上班?Android自定义列表视图
以下是我的班级代码。
public class customArray extends ArrayAdapter<String> {
SatMain sm = new SatMain();
int resource;
public customArray(Context cont, int _resource, List<String> items) {
super(cont, _resource, items);
resource = _resource;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
RelativeLayout rl;
String prod = getItem(position);
if (convertView == null) {
rl = new RelativeLayout(getContext());
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
vi.inflate(resource, rl, true);
} else {
rl = (RelativeLayout) convertView;
}
TextView t1 = (TextView) rl.findViewById(R.id.text12);
t1.setText(prod);
final Button b1 = (Button) rl.findViewById(R.id.widget29);
b1.setText("efwrf");
if (position == 2) {
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(customArray.class, SatMain.class);
startActivity(intent);
b1.setText("alarm set");
}
});
}
if (position == 0) {
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
b1.setText("number 0");
}
return rl;
}
}
发生了什么错误? – 2010-02-21 18:57:22
它只是sais意图的构造函数是未定义的(没有运行它作为它的编译错误) – SamB09 2010-02-21 19:11:13