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