一个方法中的Android super.setContentView()会导致错误吗?

时间:2012-03-15 19:18:44

标签: java android

为什么要调用super.setContentView()

在一个方法中导致android进程意外终止? 但当我删除它工作正常?

package com.example.debuggingTest;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.*;



public class TestDebugingActivity extends Activity implements OnTouchListener {


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.start);

    ImageView start = (ImageView)findViewById(R.id.imageView1);
    Button signin = (Button)findViewById(R.id.button1);
    signin.setOnTouchListener(this);
    start.setOnTouchListener(this);



  }

public boolean onTouch(View v, MotionEvent event) {
    // TODO Auto-generated method stub
    Button signin = (Button)findViewById(R.id.button1);
    Button register = (Button)findViewById(R.id.button2);


    register.setText(event.toString());
    signin.setText(String.valueOf(event.getPointerCount()));


    if(event.getPointerCount() >= 3) {
        signin.setText("Working");

//
//THIS CAUSES THE ERROR
//
        super.setContentView(R.layout.linear);

    }

    return true;

}



}

0 个答案:

没有答案