onClick(DialogInterface dialog, int which)和onClick(View v)的差别。分不多,先谢谢指点! 20
我在重写onclicklistener方法的时候eclipse给我自动生成了onClick(DialogInterfacedialog,intwhich){}方法,可是我...
我在重写onclicklistener方法的时候eclipse给我自动生成了onClick(DialogInterface dialog, int which){}方法,可是我用setOnClickListener()时模拟器运行错误,我看视频上用的是onClick(View v){}方法,可是我的sdk1.6并没有这个方法啊!哪个大虾给指点下吧!
附代码:
public class Activity01 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView myTextView = (TextView)findViewById(R.id.myTextView);
Button myButton = (Button)findViewById(R.id.myButton);
myTextView.setText("我的第一个TextView");
myButton.setText("我的第一个Button");
myButton.setOnClickListener((android.view.View.OnClickListener) new myButtonListener());
}
class myButtonListener implements OnClickListener{
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(Activity01.this, Activity02.class);
}
}
} 展开
附代码:
public class Activity01 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView myTextView = (TextView)findViewById(R.id.myTextView);
Button myButton = (Button)findViewById(R.id.myButton);
myTextView.setText("我的第一个TextView");
myButton.setText("我的第一个Button");
myButton.setOnClickListener((android.view.View.OnClickListener) new myButtonListener());
}
class myButtonListener implements OnClickListener{
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(Activity01.this, Activity02.class);
}
}
} 展开
展开全部
import android.view.View.OnClickListener;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询