当前位置: 代码迷 >> Android >> Android新人 按照视频操作结果无法实现两个Activity的跳转 mainfest注册没有关问题,可以单独实现
  详细解决方案

Android新人 按照视频操作结果无法实现两个Activity的跳转 mainfest注册没有关问题,可以单独实现

热度:78   发布时间:2016-04-28 03:50:28.0
Android新人 按照视频操作结果无法实现两个Activity的跳转 mainfest注册没问题,可以单独实现。
package abc;


import com.example.abc.R;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Act extends Activity {

/** Called when the activity is first created. */
private  Button myButton=null;
 class MyButtonListener implements OnClickListener{
     public void onClick(View v) {View v无法直接显示,[email protected]
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub

}

     // TODO Auto-generated method stub
     Intent intent=new Intent();
     intent.setClass(Act.this, other.class);
     Act.this.startAct   }*/ivity(intent);
     }
 
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    myButton = (Button)findViewById(R.id.myButton);
    myButton.setText("dfdd");
  [color=#FF0000]  myButton.setOnClickListener(new MyButtonListener());也会报错,出现 (android.view.View.OnClickListener) new MyButtonListener())/color]
}

}
 刚上大二,昨晚和下午弄了好久。。。。
------解决思路----------------------

import android.content.DialogInterface.OnClickListener;
换成
import android.view.View.OnClickListener;
  相关解决方案