Dialogox中的按钮单击侦听器问题

时间:2018-09-19 07:14:27

标签: android alertdialog android-alertdialog

我正在尝试从父对话框中打开一个子对话框,它工作正常。其中有几个按钮。我面临的问题是子对话框中的单击侦听器没有响应,并且子对话框没有关闭。

public class NoteListAdapter  extends RecyclerView.Adapter<NoteListAdapter.NoteListHolder>{

private Context context;
private LayoutInflater inflater;
private ItemModel current;
public List<ItemModel> data;
SubListAdapter adapter;
NoteListHolder holder;
String get_text;
EditText et_get_text;
AlertDialog alert_dialog, tag_alert_dialog;
String id;
LinearLayout tag_important, tag_study, tag_progress, tag_normal, tag_watchlist, tag_shopping, tag_food,tag_enterain,
        tag_transport, tag_services, tag_health;
TextView set_date;
String tag_text, tag_color;
private List<TagsModel> tagList;
String note_id;
RecyclerView sub_recycler;

/* constructor */

public NoteListAdapter(Context context, List<ItemModel> data) {

    inflater = LayoutInflater.from(context);
    this.context = context;
    this.data = data;
}


/* notify on item delete */

public void removeItem(int position) {
    data.remove(position);
    notifyItemRemoved(position);
    notifyDataSetChanged();
}

/* delete all items */
public void removeAll() {
    data.clear();
    notifyDataSetChanged();
}

@Override
public NoteListAdapter.NoteListHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    View rootView = inflater.inflate(R.layout.note_recycler, parent, false);
    holder = new NoteListHolder(rootView);
    return holder;
}

@Override
public void onBindViewHolder(NoteListAdapter.NoteListHolder holder, int position) {

    current = data.get(position);
    // tag_current = tag_data.get(position);
   String  note_id = data.get(position).getId();
    Log.d("note_idm","note id "+note_id);

    ListNoteDataBase dataBase = new ListNoteDataBase(context);
    dataBase.open();
    dataBase.inserttags("abc ", note_id, "ef1232");
    tagList = dataBase.getTagList(note_id);

        String text = tagList.get(position).getTag();
        String col = tagList.get(position).getTag_color();

    final String input_text = current.getText();
    holder.note_text.setText(input_text);

        holder.tag_view.setText(text);
    dataBase.close();

    // holder.tagCircle.setColor(Color.parseColor("#" + col));
    //holder.tagCircle.setColor(tag_color);*/

}

@Override
public int getItemCount() {
    return data.size();
}

/* edit item from recycler view */

public void restoreItem(ItemModel item, int position) {
    data.add(position, item);
    notifyItemInserted(position);
}



/* declare and initialize NoteListHolder class*/

class NoteListHolder extends RecyclerView.ViewHolder{
    private TextView note_text, tag_view;
    public RelativeLayout viewBackground, viewForeground;
    String note_txt_str;
    LinearLayout add_tag;
    Button tag_set;
    public GradientDrawable tagCircle;

    public NoteListHolder(View itemView) {
        super(itemView);
        note_text = itemView.findViewById(R.id.note_text);
        viewBackground = itemView.findViewById(R.id.view_background);
        viewForeground = itemView.findViewById(R.id.view_foreground);
        tag_view = itemView.findViewById(R.id.tag_view);
        tagCircle = (GradientDrawable) tag_view.getBackground();

        viewForeground.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int pos = getAdapterPosition();
                note_id = data.get(pos).getId();
                Log.d("note_id", "note id " + note_id);
                Bundle b = new Bundle();
                b.putString("note_id", note_id);
                edit_dialog();
            }
        });
    }

    private void edit_dialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setView(R.layout.notedialog);
        builder.setTitle("Edit Note");
       // alert_dialog = builder.create();
        alert_dialog = builder.show();
        alert_dialog.show();
        et_get_text = alert_dialog.findViewById(R.id.txtNote);
        sub_recycler = alert_dialog.findViewById(R.id.recycler_dialog);

        add_tag = alert_dialog.findViewById(R.id.add_tag);
        add_tag.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.setView(R.layout.tag_dialog);
                builder.setTitle("Select Tag");
                //tag_alert_dialog = builder.create();
                tag_alert_dialog = builder.show();
                tag_alert_dialog.getWindow().setGravity(Gravity.BOTTOM);
                tag_alert_dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
                tag_alert_dialog.show();

                tag_important = tag_alert_dialog.findViewById(R.id.tag_imp);
                tag_food = tag_alert_dialog.findViewById(R.id.tag_food);
                tag_enterain = tag_alert_dialog.findViewById(R.id.tag_enterainment);
                tag_normal = tag_alert_dialog.findViewById(R.id.tag_normal);
                tag_health = tag_alert_dialog.findViewById(R.id.tag_health);
                tag_transport = tag_alert_dialog.findViewById(R.id.tag_transport);
                tag_study = tag_alert_dialog.findViewById(R.id.tag_study);
                tag_services = tag_alert_dialog.findViewById(R.id.tag_services);
                tag_shopping = tag_alert_dialog.findViewById(R.id.tag_shop);
                tag_progress = tag_alert_dialog.findViewById(R.id.tag_progress);
                tag_watchlist = tag_alert_dialog.findViewById(R.id.tag_watchlist);
                tag_set = tag_alert_dialog.findViewById(R.id.set_tag);

                tag_important.setOnClickListener(this);
                tag_food.setOnClickListener(this);
                tag_enterain.setOnClickListener(this);
                tag_normal.setOnClickListener(this);
                tag_health.setOnClickListener(this);
                tag_transport.setOnClickListener(this);
                tag_study.setOnClickListener(this);
                tag_services.setOnClickListener(this);
                tag_shopping.setOnClickListener(this);
                tag_progress.setOnClickListener(this);
                tag_watchlist.setOnClickListener(this);

                ListNoteDataBase appDatabase = new ListNoteDataBase(context);
                appDatabase.open();
                tagList = appDatabase.getTagList(note_id);
                String tag_id = tagList.get(getAdapterPosition()).getTagId();
                int id = v.getId();
                switch (id) {
                    case R.id.tag_imp:
                        tag_text = "Important";
                        tag_color = "C61F2B";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_progress:
                        tag_text = "Progress";
                        tag_color = "A50CE2";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_study:
                        tag_text = "Study";
                        tag_color = "FCA81D";
                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_watchlist:
                        tag_text = "Watchlist";
                        tag_color = "F4C664";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_normal:
                        tag_text = "Normal";
                        tag_color = "10CAC5";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();


                        break;
                    case R.id.tag_shop:
                        tag_text = "Shopping";
                        tag_color = "15B412";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();


                        break;
                    case R.id.tag_food:
                        tag_text = "Food & Drinks";
                        tag_color = "F15696";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_enterainment:
                        tag_text = "Entertainment";
                        tag_color = "A3128E";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_transport:
                        tag_text = "Transportation";
                        tag_color = "3324BD";
                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_services:
                        tag_text = "Services";
                        tag_color = "#F3C861";
                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_health:
                        tag_text = "Health";
                        tag_color = "EC4A3A";
                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    default:
                        tag_text = "";
                        tag_color = "ffffff";
                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();
                        break;
                }

                    tag_set.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      //  if (tag_alert_dialog.isShowing()) {
                            tag_alert_dialog.hide();
                        //}
                    }
                });
            }
        });
        final EditText et_sub_txt = alert_dialog.findViewById(R.id.et_subNote);
        ImageButton sub_action = alert_dialog.findViewById(R.id.action_done);

        sub_action.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String sub_text_str = et_sub_txt.getText().toString();
                InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                ListNoteDataBase appDatabase = new ListNoteDataBase(context);
                appDatabase.open();
                appDatabase.insertsubnotes(sub_text_str, note_id);
                appDatabase.close();
                subNote_adapter();
                et_sub_txt.getText().clear();
                et_sub_txt.clearFocus();
            }
        });
        subNote_adapter();

        set_date = alert_dialog.findViewById(R.id.creation_date);
        String get_date = data.get(getAdapterPosition()).getDate();
        set_date.setText(get_date);

        String show_dia_text = data.get(getAdapterPosition()).getText();
        id = data.get(getAdapterPosition()).getId();


        //set_date.setText((CharSequence) update_date);

        /*set cursor position */

        note_txt_str = note_text.getText().toString();
        et_get_text.setText(note_txt_str);
        int position = show_dia_text.length();
        et_get_text.setSelection(position);

        Button button_edit_done = alert_dialog.findViewById(R.id.edit_note);
        button_edit_done.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                get_text = et_get_text.getText().toString().trim();
                InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                ListNoteDataBase appDatabase = new ListNoteDataBase(context);
                appDatabase.open();
                appDatabase.updateNotes(get_text, id);
                appDatabase.close();
                note_text.setText(get_text);
                if (alert_dialog.isShowing()) {
                    alert_dialog.dismiss();
                }

            }
        });
        setOnDoneButton();
    }

    private void setOnDoneButton() {
        et_get_text.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    get_text = et_get_text.getText().toString().trim();
                    ListNoteDataBase appDatabase = new ListNoteDataBase(context);
                    appDatabase.open();
                    appDatabase.updateNotes(get_text, id);
                    appDatabase.close();
                    note_text.setText(get_text);

                    if (alert_dialog.isShowing()) {
                        alert_dialog.dismiss();
                    }
                }
                return false;
            }
        });
    }

    private void subNote_adapter() {
        //  recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL,false));
        // recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
        sub_recycler.setLayoutManager(new GridLayoutManager(context, 1));
        ListNoteDataBase appDatabase = new ListNoteDataBase(context);
        appDatabase.open();
        adapter = new SubListAdapter(context, appDatabase.getSubList(note_id));
        sub_recycler.setAdapter(adapter);
        adapter.notifyDataSetChanged();
        appDatabase.close();
    }

}

}

上面的代码是用我的适配器编写的。我想通过单击按钮并关闭对话框来获取标签文本和标签颜色的值。但是它没有实现任何点击监听器。

3 个答案:

答案 0 :(得分:1)

您尝试过这些吗

 android:clickable="true"
 android:focusable="true"

您的儿童警报对话框的主要布局?

答案 1 :(得分:1)

代替上下文添加  view.getRootView().getContext()

我认为它将解决

答案 2 :(得分:1)

public class NoteListAdapter  extends RecyclerView.Adapter<NoteListAdapter.NoteListHolder>{

private Context context;
private LayoutInflater inflater;
private ItemModel current;
public List<ItemModel> data;
SubListAdapter adapter;
NoteListHolder holder;
String get_text;
EditText et_get_text;
AlertDialog alert_dialog, tag_alert_dialog;
String id;
LinearLayout tag_important, tag_study, tag_progress, tag_normal, tag_watchlist, tag_shopping, tag_food,tag_enterain,
        tag_transport, tag_services, tag_health;
TextView set_date;
String tag_text, tag_color;
private List<TagsModel> tagList;
String note_id;
RecyclerView sub_recycler;

/* constructor */

public NoteListAdapter(Context context, List<ItemModel> data) {

    inflater = LayoutInflater.from(context);
    this.context = context;
    this.data = data;
}


/* notify on item delete */

public void removeItem(int position) {
    data.remove(position);
    notifyItemRemoved(position);
    notifyDataSetChanged();
}

/* delete all items */
public void removeAll() {
    data.clear();
    notifyDataSetChanged();
}

@Override
public NoteListAdapter.NoteListHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    View rootView = inflater.inflate(R.layout.note_recycler, parent, false);
    holder = new NoteListHolder(rootView);
    return holder;
}

@Override
public void onBindViewHolder(NoteListAdapter.NoteListHolder holder, int position) {

    current = data.get(position);
    // tag_current = tag_data.get(position);
   String  note_id = data.get(position).getId();
    Log.d("note_idm","note id "+note_id);

    ListNoteDataBase dataBase = new ListNoteDataBase(context);
    dataBase.open();
    dataBase.inserttags("abc ", note_id, "ef1232");
    tagList = dataBase.getTagList(note_id);

        String text = tagList.get(position).getTag();
        String col = tagList.get(position).getTag_color();

    final String input_text = current.getText();
    holder.note_text.setText(input_text);

        holder.tag_view.setText(text);
    dataBase.close();

    // holder.tagCircle.setColor(Color.parseColor("#" + col));
    //holder.tagCircle.setColor(tag_color);*/

}

@Override
public int getItemCount() {
    return data.size();
}

/* edit item from recycler view */

public void restoreItem(ItemModel item, int position) {
    data.add(position, item);
    notifyItemInserted(position);
}



/* declare and initialize NoteListHolder class*/

class NoteListHolder extends RecyclerView.ViewHolder{
    private TextView note_text, tag_view;
    public RelativeLayout viewBackground, viewForeground;
    String note_txt_str;
    LinearLayout add_tag;
    Button tag_set;
    public GradientDrawable tagCircle;

    public NoteListHolder(View itemView) {
        super(itemView);
        note_text = itemView.findViewById(R.id.note_text);
        viewBackground = itemView.findViewById(R.id.view_background);
        viewForeground = itemView.findViewById(R.id.view_foreground);
        tag_view = itemView.findViewById(R.id.tag_view);
        tagCircle = (GradientDrawable) tag_view.getBackground();

        viewForeground.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int pos = getAdapterPosition();
                note_id = data.get(pos).getId();
                Log.d("note_id", "note id " + note_id);
                Bundle b = new Bundle();
                b.putString("note_id", note_id);
                edit_dialog();
            }
        });
    }

    private void edit_dialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setView(R.layout.notedialog);
        builder.setTitle("Edit Note");
       // alert_dialog = builder.create();
        alert_dialog = builder.show();
        //alert_dialog.show();
        et_get_text = alert_dialog.findViewById(R.id.txtNote);
        sub_recycler = alert_dialog.findViewById(R.id.recycler_dialog);

        add_tag = alert_dialog.findViewById(R.id.add_tag);
        add_tag.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.setView(R.layout.tag_dialog);
                builder.setTitle("Select Tag");
                //tag_alert_dialog = builder.create();
                tag_alert_dialog = builder.show();
                tag_alert_dialog.getWindow().setGravity(Gravity.BOTTOM);
                tag_alert_dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
                //tag_alert_dialog.show();

                tag_important = tag_alert_dialog.findViewById(R.id.tag_imp);
                tag_food = tag_alert_dialog.findViewById(R.id.tag_food);
                tag_enterain = tag_alert_dialog.findViewById(R.id.tag_enterainment);
                tag_normal = tag_alert_dialog.findViewById(R.id.tag_normal);
                tag_health = tag_alert_dialog.findViewById(R.id.tag_health);
                tag_transport = tag_alert_dialog.findViewById(R.id.tag_transport);
                tag_study = tag_alert_dialog.findViewById(R.id.tag_study);
                tag_services = tag_alert_dialog.findViewById(R.id.tag_services);
                tag_shopping = tag_alert_dialog.findViewById(R.id.tag_shop);
                tag_progress = tag_alert_dialog.findViewById(R.id.tag_progress);
                tag_watchlist = tag_alert_dialog.findViewById(R.id.tag_watchlist);
                tag_set = tag_alert_dialog.findViewById(R.id.set_tag);

               View.OnClickListener listener=new View.OnClickListener(){
                @Override
                public void onClick(View v) {
                int id = v.getId();
                switch (id) {
                    case R.id.tag_imp:
                        tag_text = "Important";
                        tag_color = "C61F2B";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_progress:
                        tag_text = "Progress";
                        tag_color = "A50CE2";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_study:
                        tag_text = "Study";
                        tag_color = "FCA81D";
                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_watchlist:
                        tag_text = "Watchlist";
                        tag_color = "F4C664";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_normal:
                        tag_text = "Normal";
                        tag_color = "10CAC5";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();


                        break;
                    case R.id.tag_shop:
                        tag_text = "Shopping";
                        tag_color = "15B412";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();


                        break;
                    case R.id.tag_food:
                        tag_text = "Food & Drinks";
                        tag_color = "F15696";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_enterainment:
                        tag_text = "Entertainment";
                        tag_color = "A3128E";

                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_transport:
                        tag_text = "Transportation";
                        tag_color = "3324BD";
                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_services:
                        tag_text = "Services";
                        tag_color = "#F3C861";
                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    case R.id.tag_health:
                        tag_text = "Health";
                        tag_color = "EC4A3A";
                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();

                        break;
                    default:
                        tag_text = "";
                        tag_color = "ffffff";
                        appDatabase.updateTags(tag_text, tag_id, tag_color);
                        appDatabase.close();
                        break;
                }
                   }
                };

                tag_important.setOnClickListener(listener);
                tag_food.setOnClickListener(listener);
                tag_enterain.setOnClickListener(listener);
                tag_normal.setOnClickListener(listener);
                tag_health.setOnClickListener(listener);
                tag_transport.setOnClickListener(listener);
                tag_study.setOnClickListener(listener);
                tag_services.setOnClickListener(listener);
                tag_shopping.setOnClickListener(listener);
                tag_progress.setOnClickListener(listener);
                tag_watchlist.setOnClickListener(listener);

                ListNoteDataBase appDatabase = new ListNoteDataBase(context);
                appDatabase.open();
                tagList = appDatabase.getTagList(note_id);
                String tag_id = tagList.get(getAdapterPosition()).getTagId();


                    tag_set.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      //  if (tag_alert_dialog.isShowing()) {
                            tag_alert_dialog.hide();
                        //}
                    }
                });
            }
        });
        final EditText et_sub_txt = alert_dialog.findViewById(R.id.et_subNote);
        ImageButton sub_action = alert_dialog.findViewById(R.id.action_done);

        sub_action.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String sub_text_str = et_sub_txt.getText().toString();
                InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                ListNoteDataBase appDatabase = new ListNoteDataBase(context);
                appDatabase.open();
                appDatabase.insertsubnotes(sub_text_str, note_id);
                appDatabase.close();
                subNote_adapter();
                et_sub_txt.getText().clear();
                et_sub_txt.clearFocus();
            }
        });
        subNote_adapter();

        set_date = alert_dialog.findViewById(R.id.creation_date);
        String get_date = data.get(getAdapterPosition()).getDate();
        set_date.setText(get_date);

        String show_dia_text = data.get(getAdapterPosition()).getText();
        id = data.get(getAdapterPosition()).getId();


        //set_date.setText((CharSequence) update_date);

        /*set cursor position */

        note_txt_str = note_text.getText().toString();
        et_get_text.setText(note_txt_str);
        int position = show_dia_text.length();
        et_get_text.setSelection(position);

        Button button_edit_done = alert_dialog.findViewById(R.id.edit_note);
        button_edit_done.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                get_text = et_get_text.getText().toString().trim();
                InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                ListNoteDataBase appDatabase = new ListNoteDataBase(context);
                appDatabase.open();
                appDatabase.updateNotes(get_text, id);
                appDatabase.close();
                note_text.setText(get_text);
                if (alert_dialog.isShowing()) {
                    alert_dialog.dismiss();
                }

            }
        });
        setOnDoneButton();
    }

    private void setOnDoneButton() {
        et_get_text.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    get_text = et_get_text.getText().toString().trim();
                    ListNoteDataBase appDatabase = new ListNoteDataBase(context);
                    appDatabase.open();
                    appDatabase.updateNotes(get_text, id);
                    appDatabase.close();
                    note_text.setText(get_text);

                    if (alert_dialog.isShowing()) {
                        alert_dialog.dismiss();
                    }
                }
                return false;
            }
        });
    }

    private void subNote_adapter() {
        //  recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL,false));
        // recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
        sub_recycler.setLayoutManager(new GridLayoutManager(context, 1));
        ListNoteDataBase appDatabase = new ListNoteDataBase(context);
        appDatabase.open();
        adapter = new SubListAdapter(context, appDatabase.getSubList(note_id));
        sub_recycler.setAdapter(adapter);
        adapter.notifyDataSetChanged();
        appDatabase.close();
    }

}