首页 > 其他分享 >简单记事本app4

简单记事本app4

时间:2023-03-18 23:46:27浏览次数:34  
标签:layout title app4 简单 et android unan id 记事本

——新增便签——

activity_note_add.xml  界面设计

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:background="@color/yellow"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="OvO"
android:textColor="@color/orange"
android:textSize="35sp"
android:gravity="center"
android:layout_marginTop="100dp"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="70dp">
<EditText
android:id="@+id/an_et_title"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="16sp"
android:textColor="@color/black"
android:hint=" 标题"
android:maxLines="1"
android:background="@drawable/bg_frame"
/>
<EditText
android:id="@+id/an_et_keywords"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="16dp"
android:textColor="@color/black"
android:hint=" 关键字"
android:layout_marginTop="5dp"
android:maxLines="1"
android:background="@drawable/bg_frame"
/>
<EditText
android:id="@+id/an_et_contents"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="16dp"
android:textColor="@color/black"
android:hint=" 内容"
android:layout_marginTop="5dp"
android:maxLines="1"
android:background="@drawable/bg_frame"
/>
</LinearLayout>

<Button
android:id="@+id/an_addnote_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="添加事件"
android:textColor="@color/black"
android:background="@drawable/bg_frame"
android:layout_marginLeft="2dp"
android:layout_marginTop="50dp"
/>

</LinearLayout>

Note Add Activity.Java

package com.example.text002;

import static db.DBManager.insertNote;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class NoteAddActivity extends AppCompatActivity implements View.OnClickListener {

private Button an_addnote_btn;
private EditText an_et_title, an_et_keywords, an_et_contents, an_et_daytime;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_note_add);
initfun();
}

private void initfun() {
an_et_title = findViewById(R.id.an_et_title);
an_et_keywords = findViewById(R.id.an_et_keywords);
an_et_contents = findViewById(R.id.an_et_contents);
//an_et_daytime = findViewById(R.id.an_et_daytime);

an_addnote_btn = findViewById(R.id.an_addnote_btn);
an_addnote_btn.setOnClickListener(NoteAddActivity.this);
}

@Override
public void onClick(View view) {
int vid = view.getId();
if(vid == R.id.an_addnote_btn){
//注册
String unan_et_title = an_et_title.getText().toString();
String unan_et_keywords = an_et_keywords.getText().toString();
String unan_et_contents = an_et_contents.getText().toString();
//String unan_et_daytime = an_et_daytime.getText().toString();
//title,keywords,contents,daytime
unan_et_title = isnull(unan_et_title);
unan_et_contents = isnull(unan_et_contents);
//unan_et_daytime = isnull(unan_et_daytime);
Boolean flag = insertNote(unan_et_title, unan_et_keywords, unan_et_contents);//, unan_et_daytime);
if(flag){
Toast.makeText(this,"事件添加成功OvO",Toast.LENGTH_SHORT).show();
Intent intent = new Intent(NoteAddActivity.this,FunctionActivity.class);
startActivity(intent);
} else {
Toast.makeText(this,"事件添加失败TAT",Toast.LENGTH_SHORT).show();
}
}
}

private String isnull(String str) {
if(str.length() == 0 || str == null){
str = " ";
}
return str;
}
}

标签:layout,title,app4,简单,et,android,unan,id,记事本
From: https://www.cnblogs.com/yansans/p/17232214.html

相关文章

  • 简单记事本app5
    ListView部分相关代码packagedb;importandroid.content.Context;importandroid.view.View;importandroid.view.ViewGroup;importandroid.widget.BaseAdapter;import......
  • 简单记事本app6
    连接数据库packagedb;importandroid.content.Context;importandroid.database.sqlite.SQLiteDatabase;importandroid.database.sqlite.SQLiteOpenHelper;importandro......
  • 简单记事本app7
    CRDU部分(不完全)packagedb;importandroid.content.Context;importandroid.database.Cursor;importandroid.database.sqlite.SQLiteDatabase;importjava.text.SimpleDa......
  • 简单记事本app2
    ——注册——activity_login.xml注册页面设计<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"......
  • 简单记事本app3
    ——登录之后——activity_function.xml   ListView实现滚动浏览,不过这一部分还没做完,目前浏览操作还没有连接上数据库<?xmlversion="1.0"encoding="utf-8"?><Li......
  • 简单的记事本app1
    (因为时间原因功能尚不全面,之后会继续更新)放一下目录结构,大体会用到这些——(有对应activity.xxx.xml的,创建的时候要创建activity,不要单独创建java文件)   ——这一篇......
  • nchan 集成keydb简单测试&一些说明
    因为keydb是完整兼容redis的,所以对于单机版本的兼容是很简单的,配置就行了参考单机运行docker-compose文件version:'3'services:db3:imag......
  • maven的原理、配置与简单应用
    目录1Java中的依赖和jar文件2依赖仓库的设计与实现3maven项目 - 3.1maven的配置:配置settings.xml、建立本地仓库目录maven-repo - 3.2maven的使用:以Spring......
  • 【基础算法】简单排序-冒泡排序
    【基础算法】简单排序-冒泡排序BubbleSortisthesimplestsortingalgorithmthatworksbyrepeatlyswappingtheadjacentelementsiftheyareinthewrongorde......
  • 一次简单的性能测试记录
     性能测试1.性能测试的场景:对性能压测接口:抢购进行测试 过程:刚开始没有提供接口,自己去页面抓包然后通过登录接口获取token才能去验证"藏品详情""藏品列......