eclipse有困难,关于那个setOnClickListener问题的谢谢了!真心想学好,求大神帮助
packagecom.example.wodebutton;importandroid.os.Bundle;importandroid.annotation.Suppre...
package com.example.wodebutton;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
@SuppressLint("ShowToast")
@SuppressWarnings("unused")
public class MainActivity extends Activity {
private Button btn1=null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1=(Button)findViewById(R.id.btn1);
btn1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "nidian", Toast.LENGTH_LONG);
}
});
}
} 展开
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
@SuppressLint("ShowToast")
@SuppressWarnings("unused")
public class MainActivity extends Activity {
private Button btn1=null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1=(Button)findViewById(R.id.btn1);
btn1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "nidian", Toast.LENGTH_LONG);
}
});
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询