File--New--Android application Project
取消勾选Create activity
src文件中新建类 MainActivity
主类继承Activity
public class MainActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.mainactivity); } }
setContentView(R.drawable 调import com.example.activity.R;
创建layout---mainactivity.xml
在AndroidManifest.xml中设置
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="lianxi.MainActivity"> //包名+类名
<intent-filter > <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER" /> //是程序能显示在手机程序列表中
</intent-filter> </activity> </application>