I am new to Android development in Eclipse, and for some reason, when trying to run my Java code, Eclipse ignores it and only runs the XML code.
Here is my Java code so far:
package com.example.boat;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ScrollView mainView = new ScrollView(this);
LinearLayout mainLayout = new LinearLayout(this);
LinearLayout results = new LinearLayout(this);
mainView.addView(mainLayout);
mainLayout.addView(results);
results.setVisibility(View.GONE);
TextView mhs = new TextView(this);
mhs.setText("Maximum hull speed:");
mainLayout.addView(mhs);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Here is my XML code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.boat"
android:versionCode="1"
android:versionName="1.0" android:installLocation="auto">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.ser421assignment4.MainActivity"
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>
Does anyone know what is wrong here? I prefer to use Java, not XML.