请帮我看下这段代码哪里有问题,运行AVD的时候提示 unfortunately,xx has stopped 的提示 小弟刚学安卓 30
packagecom.massage.wsh;//接口部分省略了publicclassMainActivityextendsActionBarActivity{priva...
package com.massage.wsh;
//接口部分省略了
public class MainActivity extends ActionBarActivity {
private Button mButton1;
private EditText mEditText1;
private EditText mEditText2;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mEditText1=(EditText)findViewById(R.id.editText1);
mEditText1.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
// TODO Auto-generated method stub
String value=arg0.getText().toString();
Toast.makeText(MainActivity.this, value ,Toast.LENGTH_LONG).show();
return false;
}
});
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}
布局代码:
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:ems="10"
android:hint="请输入收件人信息"
android:inputType="textPersonName" /> 展开
//接口部分省略了
public class MainActivity extends ActionBarActivity {
private Button mButton1;
private EditText mEditText1;
private EditText mEditText2;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mEditText1=(EditText)findViewById(R.id.editText1);
mEditText1.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
// TODO Auto-generated method stub
String value=arg0.getText().toString();
Toast.makeText(MainActivity.this, value ,Toast.LENGTH_LONG).show();
return false;
}
});
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}
布局代码:
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:ems="10"
android:hint="请输入收件人信息"
android:inputType="textPersonName" /> 展开
2个回答
展开全部
漏了android:textSize=" "
追问
我已经解决了 原因是我的java代码里边调用了两个布局文件 删掉一个就好了
谢谢你们的解答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询