国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

基于Android Studio 開發(fā)的簡易記事本

這篇具有很好參考價值的文章主要介紹了基于Android Studio 開發(fā)的簡易記事本。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

??文章末尾有獲取完整項目源碼方式??

目錄

一、引言

視頻效果展示:

圖片效果展示:

二、詳細設計

1.首頁

2.添加和修改頁面

3.登錄頁

4.注冊頁

三、獲取源碼


一、引言

? ? ? ? ?Android初學者開發(fā)第一個完整的基礎實例項目應該就屬《記事本》了,該項目基于Android Studio開發(fā)使用Java語言,該項目包含SQLlit數(shù)據(jù)庫的使用、listview、等。話不多說先上成品:

視頻效果展示:

基于Android Studio 開發(fā)的簡易記事本

圖片效果展示:

登錄頁

android記事本代碼,Android,android studio,android,ide

注冊頁?

android記事本代碼,Android,android studio,android,ide

首頁

android記事本代碼,Android,android studio,android,ide

添加頁面?android記事本代碼,Android,android studio,android,ide

修改頁面

android記事本代碼,Android,android studio,android,ide

二、詳細設計

1.首頁

? ? ? ? ? 用戶進行筆記添加,使用listview顯示筆記。??

????????該代碼實現(xiàn)了一個記事本應用的主活動(NotepadActivity)。在該活動中,使用了一個ListView來顯示便簽的列表。主要包括以下幾個部分:

  1. onCreate()方法:在該方法中,設置了活動的布局文件(activity_notepad.xml),并初始化了ListView和一個添加按鈕(ImageView)。添加按鈕的點擊事件監(jiān)聽器被設置為打開另一個活動(RecordActivity)的意圖,并在該意圖中傳遞了一個請求碼(1)。

  2. initData()方法:該方法被調(diào)用來初始化數(shù)據(jù)。在該方法中,清空了列表數(shù)據(jù)(如果存在),并從SQLite數(shù)據(jù)庫中查詢數(shù)據(jù),并將查詢結果傳遞給自定義的適配器(NotepadAdapter)。最后,將適配器設置給ListView。

  3. showQueryData()方法:該方法用于顯示查詢的數(shù)據(jù)。在該方法中,先清空列表數(shù)據(jù)(如果存在),然后再從SQLite數(shù)據(jù)庫中查詢數(shù)據(jù),并將查詢結果傳遞給適配器,最后將適配器設置給ListView。

  4. onActivityResult()方法:當從另一個活動(RecordActivity)返回時,該方法會被調(diào)用。在該方法中,檢查返回的請求碼和結果碼,如果滿足條件,則調(diào)用showQueryData()方法來顯示查詢的數(shù)據(jù)。

public class NotepadActivity extends Activity {
    ListView listView;
    List<NotepadBean> list;
    SQLiteHelper mSQLiteHelper;
    NotepadAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notepad);
        //用于顯示便簽的列表
        listView = (ListView) findViewById(R.id.listview);
        ImageView add = (ImageView) findViewById(R.id.add);
        add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(NotepadActivity.this,
                        RecordActivity.class);
                startActivityForResult(intent, 1);
            }
        });
        initData();
    }  

    }
    private void showQueryData(){
        if (list!=null){
            list.clear();
        }
        //從數(shù)據(jù)庫中查詢數(shù)據(jù)(保存的標簽)
        list = mSQLiteHelper.query();
        adapter = new NotepadAdapter(this, list);
        listView.setAdapter(adapter);
    }
    @Override
    protected void onActivityResult(int requestCode,int resultCode, Intent data){
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode==1&&resultCode==2){
            showQueryData();
        }
    }
}

2.添加和修改頁面

? ? ? ? 點擊首頁加號按鈕或者點擊列表項按鈕進行對應的頁面跳轉。

?? ? ? ?

這段代碼是一個Android應用程序中的一部分,用于初始化數(shù)據(jù)和處理點擊事件。下面對代碼進行簡要的概括:

  1. initData()?方法用于初始化數(shù)據(jù)。首先創(chuàng)建一個?SQLiteHelper?對象用于操作數(shù)據(jù)庫。然后根據(jù)傳入的?Intent?對象獲取傳遞過來的數(shù)據(jù),并根據(jù)數(shù)據(jù)的有無設置相應的文本內(nèi)容和可見性。

  2. onClick()?方法是一個點擊事件的處理方法。根據(jù)點擊的控件的id,執(zhí)行相應的操作。

    • 當點擊了id為?note_back?的控件時,調(diào)用?finish()?方法結束當前Activity。

    • 當點擊了id為?delete?的控件時,將?content?控件的文本內(nèi)容置空。

    • 當點擊了id為?note_save?的控件時,首先獲取?content?控件的文本內(nèi)容,并進行相應的操作。

      • 如果?id?不為?null,表示是修改操作。判斷內(nèi)容是否為空,若不為空,則調(diào)用?mSQLiteHelper?的?updateData()?方法進行數(shù)據(jù)庫的更新操作,并根據(jù)更新結果顯示相應的提示信息。
      • 如果?id?為?null,表示是添加操作。判斷內(nèi)容是否為空,若不為空,則調(diào)用?mSQLiteHelper?的?insertData()?方法進行數(shù)據(jù)庫的插入操作,并根據(jù)插入結果顯示相應的提示信息。

????????這段代碼的主要目的是根據(jù)傳入的數(shù)據(jù)進行新增或修改數(shù)據(jù)庫中的記錄,并根據(jù)操作結果顯示相應的提示信息。

 protected void initData() {
        mSQLiteHelper = new SQLiteHelper(this);
        noteName.setText("添加記錄");
        Intent intent = getIntent();
        if(intent!= null){
            id = intent.getStringExtra("id");
            if (id != null){
                noteName.setText("修改記錄");
                content.setText(intent.getStringExtra("content"));
                note_time.setText(intent.getStringExtra("time"));
                note_time.setVisibility(View.VISIBLE);
            }
        }
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.note_back:
                finish();
                break;
            case R.id.delete:
                content.setText("");
                break;
            case R.id.note_save:
                String noteContent=content.getText().toString().trim();
                if (id != null){//修改操作
                    if (noteContent.length()>0){
                        if (mSQLiteHelper.updateData(id, noteContent, DBUtils.getTime())){
                            showToast("修改成功");
                            setResult(2);
                            finish();
                        }else {
                            showToast("修改失敗");
                        }
                    }else {
                        showToast("修改內(nèi)容不能為空!");
                    }
                }else {
                    //向數(shù)據(jù)庫中添加數(shù)據(jù)
                    if (noteContent.length()>0){
                        if (mSQLiteHelper.insertData(noteContent, DBUtils.getTime())){
                            showToast("保存成功");
                            setResult(2);
                            finish();
                        }else {
                            showToast("保存失敗");
                        }
                    }else {
                        showToast("修改內(nèi)容不能為空!");
                    }
                }
                break;
        }

3.登錄頁

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="#fb7a6a"
    tools:context=".Login.LoginActivity">

    <LinearLayout
        android:layout_width="300dp"
        android:layout_height="0dp"
        android:gravity="center|top"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView">

        <EditText
            android:id="@+id/username_edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="請輸入賬號"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/password_edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:hint="請輸入密碼"
            android:inputType="textPassword"
            android:textSize="20sp" />

        <Button
            android:id="@+id/login_button"
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="80dp"
            android:background="@drawable/button"
            android:text="立 即 登 陸"
            android:textColor="#fff"
            android:textSize="14sp" />

        <Button
            android:id="@+id/register_button"
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:background="@drawable/button"
            android:text="立 即 注 冊"
            android:textColor="#fff"
            android:textSize="14sp" />

    </LinearLayout>

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="0dp"
        android:layout_height="200dp"
        android:scaleType="centerCrop"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/logo" />
</androidx.constraintlayout.widget.ConstraintLayout>

4.注冊頁

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="#fb7a6a"
    tools:context=".Register.RegisterActivity">

    <LinearLayout
        android:layout_width="300dp"
        android:layout_height="0dp"
        android:gravity="center|top"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView2">

        <EditText
            android:id="@+id/username_edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="請輸入賬號"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/password_edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:hint="請輸入密碼"
            android:inputType="textPassword"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/repeat"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:ems="10"
            android:hint="再次輸入您的密碼"
            android:inputType="textPassword"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/tv_login"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:gravity="center|right"
            android:text="已有賬號?立即登錄"
            android:textColor="#fff"
            android:textSize="15sp" />

        <Button
            android:id="@+id/register_button"
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="80dp"
            android:background="@drawable/button"
            android:text="立 即 注 冊"
            android:textColor="#fff"
            android:textSize="14sp" />

    </LinearLayout>

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="0dp"
        android:layout_height="200dp"
        android:scaleType="centerCrop"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/logo" />
</androidx.constraintlayout.widget.ConstraintLayout>

三、獲取源碼

關注公眾號《編程樂學》,后臺回復:23050901

????????????????????快捷獲取方式??????文章來源地址http://www.zghlxwxcb.cn/news/detail-753180.html

到了這里,關于基于Android Studio 開發(fā)的簡易記事本的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內(nèi)容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • android studio大作業(yè),android studio課程設計,記事本實現(xiàn)

    android studio大作業(yè),android studio課程設計,記事本實現(xiàn)

    先看效果圖 功能點實現(xiàn): 登錄,注冊,記事本分類添加,刪除,數(shù)據(jù)分析統(tǒng)計報表,數(shù)據(jù)庫使用SQLlite 部分實現(xiàn)代碼

    2024年02月11日
    瀏覽(27)
  • Android開發(fā)_記事本(1)

    Android開發(fā)_記事本(1)

    TextView中有下述幾個屬性: id: 為TextView設置一個組件id,根據(jù)id,我們可以在Java代碼中通過findViewById()的方法獲取到該對象,然后進行相關屬性的設置,又或者使用RelativeLayout時,參考組件用的也是id! layout_width: 組件的寬度,一般寫: wrap_content 或者 match_parent(fill_parent) ,前

    2023年04月10日
    瀏覽(33)
  • 基于安卓系統(tǒng)(android)記事本APP管理系統(tǒng)設計與實現(xiàn)

    基于安卓系統(tǒng)(android)記事本APP管理系統(tǒng)設計與實現(xiàn)

    目錄 摘要 I Abstract II 1 緒論 1.1 課題來源、目的和意義 1 1.2 國內(nèi)外基本研究情況 1 2 需求分析 2.1 用戶需求 4 2.2 功能需求 4 2.3 數(shù)據(jù)庫選擇 6 2.4 性能需求 6 3 概要設計 3.1 功能概要設計 7 3.2 數(shù)據(jù)庫概要設計 13 4 詳細設計 4.1 功能設計 15 4.2 數(shù)據(jù)庫設計 30 5 系統(tǒng)功能實現(xiàn) 5.1 系統(tǒng)架

    2024年02月11日
    瀏覽(26)
  • Android:實現(xiàn)安卓小程序-記事本(備忘錄)的開發(fā),教你如何增加拿到BAT大廠offer幾率

    Android:實現(xiàn)安卓小程序-記事本(備忘錄)的開發(fā),教你如何增加拿到BAT大廠offer幾率

    public MyBaseAdapter(Context context, List data) { this.context = context; this.data = data; } @Override public Object getItem(int i) { return null; } @Override public long getItemId(int i) { return 0; } @Override public int getCount() { if(data==null) return 0; return data.size(); } } 接著在編寫NoteAdapter類繼承上類,初始化view, 將Note條目的

    2024年04月25日
    瀏覽(91)
  • Android記事本

    Android記事本

    1、項目需求分析 1.1、記事功能需求分析: 1.1.1、顯示記事 用戶打開記事本可以看到之前所寫的所有記事內(nèi)容,進入主頁后,軟件應該從數(shù)據(jù)庫中搜索出該用戶所寫的全部記事,并將所有的數(shù)據(jù)進行顯示。 1.1.2、添加記事 設置添加按鈕,點擊添加按鈕之后可以編輯記事的標題

    2024年02月03日
    瀏覽(35)
  • Android——記事本功能業(yè)務(完整代碼)

    Android——記事本功能業(yè)務(完整代碼)

    目錄 實現(xiàn)效果 一、搭建記事本頁面布局activity_notepad.xml 二、搭建記事本界面Item布局notepad_item_layout.xml 三、封裝記錄信息實體類NotepadBean類 四、編寫記事本界面列表適配器NotepadAdapter類 五、創(chuàng)建數(shù)據(jù)庫 六、實現(xiàn)記事本界面的顯示功能NotepadAdapter.java? 七、搭建添加記錄界面和

    2024年02月03日
    瀏覽(34)
  • Android 備忘錄,記事本程序設計

    Android 備忘錄,記事本程序設計

    android備忘錄實現(xiàn),使用ObjectBox數(shù)據(jù)庫框架進行數(shù)據(jù)存儲,增刪改查等操作。代碼使用kotlin編寫。 1、下面看看ObjectBox數(shù)據(jù)庫封裝 需要注意的是: ? ?/** ? ? ?* 你只有配置好之后, 點擊 Make Model \\\'你的model名字\\\', 才會創(chuàng)建 MyObjectBox對象 ? ? ?* 對于MyObjectBox的包名, 目前我發(fā)現(xiàn)的

    2024年01月23日
    瀏覽(27)
  • 微信小程序開發(fā)筆記—記事本

    微信小程序開發(fā)筆記—記事本

    其實在一開始本人就想做一個類似日記本的功能,但是礙于最開始能力有限,而且發(fā)現(xiàn)上網(wǎng)搜索到的一些相關資料較少,看到做有其他博主做,但是使用的云開發(fā),本人暫時只想做一個簡單的無后臺的,所以沒有參考。其次也搜到一些其他內(nèi)容,真的是看了超多文章,這里貼

    2024年02月03日
    瀏覽(24)
  • 【Android 記事本,筆記本,可注冊登錄,增刪改查(附源碼)】

    【Android 記事本,筆記本,可注冊登錄,增刪改查(附源碼)】

    簡介 用Sqlite做數(shù)據(jù)庫,用來存儲賬號以及筆記信息,實現(xiàn)了賬號的注冊以及登錄功能,筆記方面實現(xiàn)了新增、刪除、修改、搜索功能,列表展示筆記使用的是listView(懶得弄分割線,就使用listView的默認分割線了); 運行效果 代碼講解 我代碼里使用了兩個依賴,一個是工具

    2024年02月04日
    瀏覽(20)
  • 安卓大作業(yè)(AndroidStudio開發(fā))日記記事本app

    安卓大作業(yè)(AndroidStudio開發(fā))日記記事本app

    博主介紹: 本人專注于Android/java/數(shù)據(jù)庫/微信小程序技術領域的開發(fā),以及有好幾年的計算機畢業(yè)設計方面的實戰(zhàn)開發(fā)經(jīng)驗和技術積累;尤其是在安卓(Android)的app的開發(fā)和微信小程序的開發(fā),很是熟悉和了解;本人也是多年的Android開發(fā)人員;希望我發(fā)布的此篇文件可以幫

    2024年02月11日
    瀏覽(19)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包