5.1(小组作业十日冲刺第七天)

继续完成昨天的内容

所花时间:3h

代码行量:369行

package com.example.memosystem.activity.listen;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

import com.example.memosystem.R;

public class ChangeListen implements TextWatcher {

private EditText ed=null;

public ChangeListen(EditText ed){
this.ed=ed;
}


@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override
public void afterTextChanged(Editable editable) {

if(editable.length()>0){

ed.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,R.drawable.x,0);
}else{
ed.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,0,0);
}
}
}
package com.example.memosystem.activity.listen;

import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;

public class TouchListen implements View.OnTouchListener{


private EditText ed=null;

public TouchListen(EditText ed){
this.ed=ed;
}

@Override
public boolean onTouch(View view, MotionEvent motionEvent) {


//
int start=ed.getWidth()-ed.getPaddingEnd()-ed.getPaddingRight();
int end=ed.getWidth();//整个文本的宽带

float x = motionEvent.getX();


boolean isButtonClicked=x>start&&x<end;
if(isButtonClicked){

if(motionEvent.getAction()==MotionEvent.ACTION_UP){
//判断是否鼠标抬起
ed.setText("");
return true;
}

}
return false;
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.AddActivity"
android:orientation="vertical"
>

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:title="心理日记"
app:navigationIcon="@drawable/back"
/>

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="20dp"
android:layout_marginTop="20dp"
>

<EditText
android:id="@+id/add_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="标题"
android:textStyle="bold"
android:textSize="30sp"
android:background="@null"
/>

<TextView
android:id="@+id/add_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="时间"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:textSize="15sp"
android:textStyle="bold"
/>
<EditText

android:id="@+id/add_con"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入内容"
android:textStyle="bold"
android:textSize="20sp"
android:background="@null"
/>









</LinearLayout>



</ScrollView>



</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.ManageActivity">


<!--主界面-->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"


>

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_man"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="#e8cb06"
app:title="@string/app_name"

app:navigationIcon="@drawable/line"
/>

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="0dp"
android:text="更多功能"
android:backgroundTint="#e8cb06"
android:textColor="@color/black"/>


<ListView
android:id="@+id/manage_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar_man"
android:padding="20dp"
android:divider="#00000000"
android:dividerHeight="18dp"

/>

</RelativeLayout>














<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="45dp"
app:elevation="6dp"
app:srcCompat="@drawable/add"
app:backgroundTint="#0288D1"
/>























</FrameLayout>

<!--侧边栏-->
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fed0d0"
android:layout_gravity="start"
android:orientation="vertical"
app:menu="@menu/manage_menu"
app:headerLayout="@layout/head_layout"
/>









</androidx.drawerlayout.widget.DrawerLayout>
posted @ 2024-05-01 23:27  不如喝点  阅读(2)  评论(0编辑  收藏  举报