Java 如何使用EditText中的数据安排每周通知?

Java 如何使用EditText中的数据安排每周通知?,java,android,Java,Android,我正在开发一个非常基本的时间表应用程序,作为高中的一个研究项目,遇到了一些我找不到解决方案的问题 我的主要(也是唯一的)布局由一个TabHost组成,其中包含五个选项卡(周一到周五) 每个选项卡包含水平线性布局的6行(六个不同的时间),其中包含两个编辑文本:一个用于主题标题,另一个用于课程编号。这意味着用户可以在不同的编辑文本中输入其个人数据。例如,安排在周一8:00的通知应该使用这些编辑文本中的数据构建 我想做的是每周创建30个通知,从周一到周五每天6个。必须触发的时间是预定义的,用户将无法更

我正在开发一个非常基本的时间表应用程序,作为高中的一个研究项目,遇到了一些我找不到解决方案的问题

我的主要(也是唯一的)布局由一个TabHost组成,其中包含五个选项卡(周一到周五)

每个选项卡包含水平线性布局的6行(六个不同的时间),其中包含两个编辑文本:一个用于主题标题,另一个用于课程编号。这意味着用户可以在不同的编辑文本中输入其个人数据。例如,安排在周一8:00的通知应该使用这些编辑文本中的数据构建

我想做的是每周创建30个通知,从周一到周五每天6个。必须触发的时间是预定义的,用户将无法更改

在activity_main.xml布局中复制30次的基本代码:

                    <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>

允许您安排应用程序在将来的某个时间运行。当警报熄灭时,系统会广播已为其注册的意图,如果目标应用程序尚未运行,则会自动启动该应用程序*

尝试
AlarmManager
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);
    }
}