I'm trying to create an android app where users can divide up the courses they took in each year of college. The idea is to have an opening screen with the button "Add Year", and when it's clicked, it creates a button above or underneath it (doesn't really matter) that they can create a custom name for. The "Add year" button has to stay so that they can add as many years/semesters/w/e as necessary. I've been following this tutorial: http://developer.android.com/training/basics/firstapp/starting-activity.html ignoring the parts about adding a text field. When it gets the the part about making your button do something, the tutorial takes the user-entered text and displays it in a new xml.
I have minimal experience in java, and turn to Google whenever I get stuck, but I haven't found anything that would help my dilemma. Here is my activity_main.xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_background"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button_add_year"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="39dp"
android:text="@string/button_add_year"
android:onClick="addYear" />
</RelativeLayout>
And my .java
package com.bkarpinski.macgpatrack;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.*;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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;
}
/** Called when the user clicks the addYear button */
public void addYear(View view) {
Intent intent = new Intent(this, CreateNewYearButton.class);
}
}
Please help me! I have to present this Wednesday, and am stuck!! D: