新建笔记 重命名

Posted _ArcticOcean

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了新建笔记 重命名相关的知识,希望对你有一定的参考价值。

private void newnote() 
    final Intent intent = new Intent(this, PaintNoteActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    View popuView = View.inflate(this, R.layout.item_createnote, null);
    final PopupWindow popupWindow = new PopupWindow(popuView, 560, 290);
    popupWindow.setBackgroundDrawable(new ColorDrawable());
    popupWindow.setFocusable(true);
    popupWindow.setAnimationStyle(R.style.PopuAnim);
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(mVpContainer, Gravity.CENTER, 0, 0);
    long ti = System.currentTimeMillis();
    String dirpath = Constants.NOTEPATH + FileUtils.getTime5(ti) + "-" + FileUtils.getCurrentTime(ti + "");
    final String dirname = FileUtils.getSplit(dirpath, 5);
    final EditText edit = (EditText) popuView.findViewById(R.id.cnote_newname);
    InputMethodManager imm = (InputMethodManager) edit.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
    edit.setText(dirname);
    popuView.findViewById(R.id.cnote_blank).setOnClickListener(new View.OnClickListener() 
        @Override
        public void onClick(View v) 
            final String newdirname = edit.getText() + "";
            String newdirpath = Constants.NOTEPATH + (TextUtils.isEmpty(newdirname) ? dirname : newdirname);
            String neweditpath = newdirpath + "/" + dirname + ".json";
            createNewJson(newdirpath, neweditpath, 0);
            intent.putExtra("backgroundtype", 0);
            intent.putExtra("dirpath", newdirpath);
            intent.putExtra("dirtitle", newdirname);
            intent.putExtra("editpath", neweditpath);
            //直接新建到/storage/emulated/legacy/Note/NoteDir/2016-XX-XX-XXXX 并传入值
            LogUtils.d("newnote   dirpath = " + newdirpath);
            LogUtils.d("newnote   dirname = " + (TextUtils.isEmpty(newdirname) ? dirname : newdirname));
            LogUtils.d("newnote   editpath = " + neweditpath);
            startActivity(intent);
            popupWindow.dismiss();
        
    );
    popuView.findViewById(R.id.cnote_horizon).setOnClickListener(new View.OnClickListener() 
        @Override
        public void onClick(View v) 
            final String newdirname = edit.getText() + "";
            String newdirpath = Constants.NOTEPATH + (TextUtils.isEmpty(newdirname) ? dirname : newdirname);
            String neweditpath = newdirpath + "/" + dirname + ".json";
            intent.putExtra("backgroundtype", 1);
            intent.putExtra("dirpath", newdirpath);
            intent.putExtra("dirtitle", newdirname);
            intent.putExtra("editpath", neweditpath);
            //直接新建到/storage/emulated/legacy/Note/NoteDir/2016-XX-XX-XXXX 并传入值
            LogUtils.d("newnote   dirpath = " + newdirpath);
            LogUtils.d("newnote   dirname = " + (TextUtils.isEmpty(newdirname) ? dirname : newdirname));
            LogUtils.d("newnote   editpath = " + neweditpath);
            startActivity(intent);
            popupWindow.dismiss();
        
    );
    popuView.findViewById(R.id.cnote_vertical).setOnClickListener(new View.OnClickListener() 
        @Override
        public void onClick(View v) 
            final String newdirname = edit.getText() + "";
            String newdirpath = Constants.NOTEPATH + (TextUtils.isEmpty(newdirname) ? dirname : newdirname);
            String neweditpath = newdirpath + "/" + dirname + ".json";
            createNewJson(newdirpath, neweditpath, 1);
            intent.putExtra("backgroundtype", 1);
            intent.putExtra("dirpath", newdirpath);
            intent.putExtra("dirtitle", newdirname);
            intent.putExtra("editpath", neweditpath);
            //直接新建到/storage/emulated/legacy/Note/NoteDir/2016-XX-XX-XXXX 并传入值
            LogUtils.d("newnote   dirpath = " + newdirpath);
            LogUtils.d("newnote   dirname = " + (TextUtils.isEmpty(newdirname) ? dirname : newdirname));
            LogUtils.d("newnote   editpath = " + neweditpath);
            startActivity(intent);
            popupWindow.dismiss();
        
    );
    popuView.findViewById(R.id.cnote_grid).setOnClickListener(new View.OnClickListener() 
        @Override
        public void onClick(View v) 
            final String newdirname = edit.getText() + "";
            String newdirpath = Constants.NOTEPATH + (TextUtils.isEmpty(newdirname) ? dirname : newdirname);
            String neweditpath = newdirpath + "/" + dirname + ".json";
            createNewJson(newdirpath, neweditpath, 2);
            intent.putExtra("backgroundtype", 2);
            intent.putExtra("dirpath", newdirpath);
            intent.putExtra("dirtitle", newdirname);
            intent.putExtra("editpath", neweditpath);
            //直接新建到/storage/emulated/legacy/Note/NoteDir/2016-XX-XX-XXXX 并传入值
            LogUtils.d("newnote   dirpath = " + newdirpath);
            LogUtils.d("newnote   dirname = " + (TextUtils.isEmpty(newdirname) ? dirname : newdirname));
            LogUtils.d("newnote   editpath = " + neweditpath);
            startActivity(intent);
            popupWindow.dismiss();
        
    );


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="560dp"
              android:layout_height="290dp"
              android:background="@drawable/button"
              android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center_vertical"
        android:paddingLeft="6dp"
        android:text="Create new note"
        android:textSize="24dp"
        android:textStyle="bold"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="4"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:text="Please input a note name"/>

        <EditText
            android:id="@+id/cnote_newname"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_weight="1"
            android:background="@drawable/button"
            android:selectAllOnFocus="true"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:text="请选择背景样式"/>

        <RadioGroup
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center_horizontal"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/cnote_blank"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/guide_blank"
                android:button="@null"
                android:scaleType="center"
                android:text="空白"/>

            <RadioButton
                android:id="@+id/cnote_vertical"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/guide_line"
                android:button="@null"
                android:scaleType="center"
                android:text="条纹1"/>

            <RadioButton
                android:id="@+id/cnote_horizon"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/guide_line"
                android:button="@null"
                android:scaleType="center"
                android:text="条纹2"/>

            <RadioButton
                android:id="@+id/cnote_grid"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/guide_rect"
                android:button="@null"
                android:scaleType="center"
                android:text="米格"/>
        </RadioGroup>
    </LinearLayout>

</LinearLayout>

以上是关于新建笔记 重命名的主要内容,如果未能解决你的问题,请参考以下文章

在excel中如何新建一个自己命名的工作簿?

C#新建文件夹,并给它命名当前时间

笔记法F2键不能重命名

用vba新建工作表,并命名

用c#做的一个目录树(可新建删除重命名)

华为电脑重命名快捷键是啥