public class MainActivity extends ActionBarActivity {
private Button button1;
private Button button2;
private Button button3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findView();
public void findView(){
button1 =(Button)findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v){
setContentView(R.layout.hi1);
button1 =(Button)findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v){
return findView();
}
});
button2 =(Button)findViewById(R.id.button2);
button2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v){
setContentView(R.layout.hi2);
button1 =(Button)findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v){
return findView2();
}
});
button3 =(Button)findViewById(R.id.button3);
button3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v){
setContentView(R.layout.hi3);
button1 =(Button)findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v){
return findView2();
}
});
}
public void findView2(){
button1 =(Button)findView2ById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v){
setContentView(R.layout.main);
}
});
}
}
錯誤訊息
To complete classbody
我想讓程式跳到finView2()
但是好像有錯誤
是不是需要使用class不再用匿名內部類別了