c = (TextView) claims.findViewById(R.id.textView49);
c.setOnClickListener(new View.OnClickListener()
{
if(c!=null)
{
@Override
public void onClick (View v){
Intent intent = new Intent(getActivity(), Receipt.class);
startActivity(intent);
}
}
});
错误:
Error:(137, 13) error: illegal start of type
Error:(137, 17) error: <identifier> expected
Error:(137, 19) error: ';' expected
Error:(140, 26) error: ';' expected
Error:(146, 14) error: ')' expected
答案 0 :(得分:0)
只需编写此代码:
c = (TextView) claims.findViewById(R.id.textView49);
if (c != null) {
c.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v){
Intent intent = new Intent(getActivity(), Receipt.class);
startActivity(intent);
}
});
}
答案 1 :(得分:0)
错误是大括号的不正确关闭......但是在应用setOnClickListener 后检查空指针是不正确的,所以将代码更改为
c = (TextView) claims.findViewById(R.id.textView49);
if(null != c){
c.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), Receipt.class);
startActivity(intent); }
});
}
答案 2 :(得分:0)
我的解决方案
if(!textViewn.getText().toString().isEmpty())
{
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}