Re: [问题] app转换layout问题

楼主: toreless2 (TOR)   2014-04-15 01:30:18
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不再用匿名内部类别了
作者: okskygo (来)   2014-04-15 02:08:00
void 不能return value
作者: slemonade (淳)   2014-04-15 08:48:00
Findview2byid??
作者: aiweisen (艾维森)   2014-04-15 10:09:00
To complete classbody自己拿去GOOGLE 检查一下 "}"另外同1F void是没有回传值 你要跳到finView2() 直接在里面呼叫finView2()就行了

Links booklink

Contact Us: admin [ a t ] ucptt.com