android程序eclipse中无错真机虚拟机运行均闪退
packagecom.example.wwktest1;importandroid.app.Activity;importandroid.os.Bundle;import...
package com.example.wwktest1;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener{
private EditText et1,et2;
private Button btn1,btn2;
private TextView tv;
//
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
et1=(EditText)findViewById(R.id.et1);
et2=(EditText)findViewById(R.id.et2);
btn1=(Button)findViewById(R.id.btn1);
btn1.setOnClickListener(this);
btn2=(Button)findViewById(R.id.btn2);
tv=(TextView)findViewById(R.id.tv);
setContentView(R.layout.activity_main);
}
@Override
public void onClick(View view){
if(view==btn1){
try {
String str1 = et1.getText().toString();
String str3 = str1;
tv.setText(str3);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
} 展开
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener{
private EditText et1,et2;
private Button btn1,btn2;
private TextView tv;
//
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
et1=(EditText)findViewById(R.id.et1);
et2=(EditText)findViewById(R.id.et2);
btn1=(Button)findViewById(R.id.btn1);
btn1.setOnClickListener(this);
btn2=(Button)findViewById(R.id.btn2);
tv=(TextView)findViewById(R.id.tv);
setContentView(R.layout.activity_main);
}
@Override
public void onClick(View view){
if(view==btn1){
try {
String str1 = et1.getText().toString();
String str3 = str1;
tv.setText(str3);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
} 展开
2个回答
展开全部
粘贴错误提示出来看看先
更多追问追答
追问
没有错误提示,就是真机运行时弹出对话框
很抱歉,"wwktest1“ 已停止工作
追答
btn1.setOnClickListener(this);把这句注释运行看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询