I'm developing a very basic TimeTable app as a research project in highschool and have ran into some problems I can't find the solution for.
My main (and only, for that matter) layout consists of a TabHost which contains five tabs (monday - friday).
Each tab houses 6 rows (Six diffent times) of a Horizontal Linear Layout that contains two EditTexts: One for the title of the subject and another one for the class number. This is meant so the user can enter its personal data in the different edittexts. The notification scheduled for example on mondays at 8:00 should be build with the data from those EditTexts.
What I want to do is to create 30 weekly notifications, 6 a day from monday to friday. The time they have to be triggered at is pre-defined and the user will not be able to change it.
Here is an image of the layout.
The basic code which is copied 30 times across the activity_main.xml layout:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="1"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/first_time"
android:textSize="20sp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/subject_hint"
android:layout_marginStart="10dp"
android:inputType="number|textCapWords"
android:id="@+id/mon_subj_1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/class_hint"
android:layout_marginStart="10dp"
android:id="@+id/mon_class_1" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/button_action_delete"
android:layout_marginStart="10dp"
android:contentDescription="@string/button_description"/>
</LinearLayout>
In the MainActivity.java file I've only added the necessary code to set up the TabHost:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//creating the TAB HOST
TabHost tabHost = (TabHost) findViewById(R.id.tabHost2);
tabHost.setup();
//setting up the 1st tab
TabHost.TabSpec tabSpec = tabHost.newTabSpec("monday");
tabSpec.setContent(R.id.monday);
tabSpec.setIndicator("Mon");
tabHost.addTab(tabSpec);
//setting up the 2nd tab
tabSpec = tabHost.newTabSpec("tuesday");
tabSpec.setContent(R.id.tuesday);
tabSpec.setIndicator("Tue");
tabHost.addTab(tabSpec);
//setting up the 3rd tab
tabSpec = tabHost.newTabSpec("wednesday");
tabSpec.setContent(R.id.wednesday);
tabSpec.setIndicator("Wed");
tabHost.addTab(tabSpec);
//setting up the 4th tab
tabSpec = tabHost.newTabSpec("thursday");
tabSpec.setContent(R.id.thursday);
tabSpec.setIndicator("Thu");
tabHost.addTab(tabSpec);
//setting up the 5th tab
tabSpec = tabHost.newTabSpec("friday");
tabSpec.setContent(R.id.friday);
tabSpec.setIndicator("Fri");
tabHost.addTab(tabSpec);
//here we have finished creating the TAB HOST
}
@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;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}