Android开发 代替 “(XXXX)findViewById()”

public class NActivity extends Activity{
protected void onCreate(Bundle savedInstanceState){
setContentView(R.layout.activity_main);
Button button=getInstances(R.id.button1);
Button button2=getInstances(R.id.button2);
TextView tv1=getInstances(R.id.textview1);
TextView tv2=getInstances(R.id.textview2);
}
protected <T extends View> T getInstances(int id) {
return (T) findViewById(id);
} }
原文地址http://www.oschina.net/code/snippet_2410256_51108

上一篇:Ecplise 配置本地 https 测试


下一篇:【BZOJ1823】【JSOI2010】满汉全席