public class Activity01<Button> extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView myTextView=(TextView)findViewById(R.id.myTextView);
Button myButton=(Button)findViewById(R.id.myButton);
myTextView.setText("我的第一个TextView");//运行时出错
myButton.setText("我的第一个Button");//运行时出错
}
}错误信息如下:
The left-hand side of an assignment must be a variable ;
Syntax error on token "Invalid Character", invalid AssignmentOperator;
Syntax error on token "Invalid Character", ; expected
求高手指教,不胜感激
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView myTextView=(TextView)findViewById(R.id.myTextView);
Button myButton=(Button)findViewById(R.id.myButton);
myTextView.setText("我的第一个TextView");//运行时出错
myButton.setText("我的第一个Button");//运行时出错
}
}错误信息如下:
The left-hand side of an assignment must be a variable ;
Syntax error on token "Invalid Character", invalid AssignmentOperator;
Syntax error on token "Invalid Character", ; expected
求高手指教,不胜感激
myButton.setText("我的第一个Button");//运行时出错
不会 中英文符号的问题吧
myButton.setText("我的第一个Button");//运行时出错
那两个冒号用英文输入时输入,重输一下
The method setText(String) is undefined for the type Button
求指教
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView myTextView=(TextView)findViewById(R.id.myTextView);
Button myButton=(Button)findViewById(R.id.myButton);//运行时出错
myTextView.setText("我的第一个TextView");
myButton.setText("我的第一个Button");
}
}
改正后运行还是出错:
Button cannot be resolved to a type
问题解决