android编译错误“OnClickListener cannot be resolved to a type”解决方案
2014-10-23 08:43
465 查看
在android代码编译时可能会出现如下错误:
部分代码:
shang.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
EditText temp = new EditText(RLtest_Activity.this);
temp.setText("上");
RelativeLayout.LayoutParams lp1 =
new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,95);
lp1.addRule(RelativeLayout.ABOVE,currButton.getId());
lp1.addRule(RelativeLayout.CENTER_HORIZONTAL,currButton.getId());
rl.addView(temp,lp1);
}
}
);
将new OnClickListener()改为new View.OnClickListener() ;//因为该函数接口在新版系统中转移到View类了
再加入一行代码:
import android.view.View.OnClickListener;//这个也可以不加
部分代码:
shang.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
EditText temp = new EditText(RLtest_Activity.this);
temp.setText("上");
RelativeLayout.LayoutParams lp1 =
new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,95);
lp1.addRule(RelativeLayout.ABOVE,currButton.getId());
lp1.addRule(RelativeLayout.CENTER_HORIZONTAL,currButton.getId());
rl.addView(temp,lp1);
}
}
);
将new OnClickListener()改为new View.OnClickListener() ;//因为该函数接口在新版系统中转移到View类了
再加入一行代码:
import android.view.View.OnClickListener;//这个也可以不加
相关文章推荐
- android编译错误“OnClickListener cannot be resolved to a type”解决方案
- android编译错误“OnClickListener cannot be resolved to a type”解决方案
- android编译错误“OnClickListener cannot be resolved to a type”
- android编译错误“OnClickListener cannot be resolved to a type”解
- android: OnClickListener cannot be resolved to a type
- 【android】:OnClickListener cannot be resolved to a type
- Android:OnClickListener cannot be resolved to a type
- Android:OnClickListener cannot be resolved to a type
- 关于“OnClickListener cannot be resolved to a type”问题
- android--jni编译错误的解决方案:.c源文件出现类似Type 'jstring' could not be resolved
- Error:OnClickListener cannot be resolved to a type
- 关于Android中“OnClickLinstener cannot be resolved to a type”的错误
- 【转】OnClickListener cannot be resolved to a type
- OnScrollListener cannot be resolved to a type 解决方案
- OnClickListener cannot be resolved to a type
- eclipse import的项目报autowired cannot be resolved to a type的错误
- xxx cannot be resolved to a type 错误解决方法
- adt "cannot be resolved to a type"错误解决办法
- Android开发中出现cannot be resolved to a variable错误,也就是R文件不能生成。
- 刚刚开始学Android,EditText cannot be resolved to a type是什么原因