运行时提示The application has stoped unexpectedly是怎么回事
代码没错,就是运行时提示The application has stoped unexpectedlyjava文件:
package mars.TextViewActivity;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;
public class TextViewActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.main);
LinearLayout l1=(LinearLayout)findViewById(R.id.textviewll);
TextView textView = new TextView(this);
//设置显示文字
textView.setText("从代码中添加一个TextView");
//设置显示颜色
textView.setTextColor(Color.WHITE);
//设置显示字体大小
textView.setTextSize(18);
//设置显示背景颜色
textView.setBackgroundColor(Color.BLUE);
//设置描点位置
textView.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL);
//把这个view加到布局中去
l1.addView(textView);
super.onCreate(savedInstanceState);
}
}
配置文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mars.TextViewActivity"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".TextViewActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
补充:移动开发 , Android