刚开始学习android的小白,可能问的问题幼稚,望见谅
Button button = (Button)findViewById(R.id.button);
TextView message = (TextView)findViewById(R.id.message);
Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
我猜想,这可能是实例化对象的另一种方式,或者是在android运行机制中已经实例化对象?
望大佬解惑
看这个代码
class Button
{
...
}
class A
{
public Object findXXXById(id) { return new Button(); } // new在这里
}
class YourApp extends A
{
public void foo()
{
//你的代码
Buton btn = (Button)findXXXById(id);
}
}
明白了么?