增加 设置功率
parent
644fb42674
commit
f16dd3f01e
@ -0,0 +1,9 @@
|
||||
package com.example.jinyu_rfid.dialog;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2024/4/25 9:12
|
||||
*/
|
||||
public interface DialogCall {
|
||||
void returnData(int power );
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.example.jinyu_rfid.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.example.jinyu_rfid.dialog.DialogCall;
|
||||
import com.example.jinyu_rfid.R;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2024/4/25 9:07
|
||||
*/
|
||||
public class MyAlertDialog extends Dialog {
|
||||
private DialogCall dialogCall;
|
||||
private int power;
|
||||
|
||||
public void setPower(int power) {
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
public void setDialogCall(DialogCall dialogCall) {
|
||||
this.dialogCall = dialogCall;
|
||||
}
|
||||
|
||||
public MyAlertDialog(Context context) {
|
||||
super(context, R.style.dialog);
|
||||
}
|
||||
private EditText editText;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.dialog_power_layout);
|
||||
|
||||
editText = findViewById(R.id.dialog_text);
|
||||
TextView textView = findViewById(R.id.dialog1_button);
|
||||
textView.setOnClickListener(view -> {
|
||||
String string = editText.getText().toString();
|
||||
if (!string.isEmpty()) {
|
||||
int power = Integer.parseInt(string);
|
||||
Log.e("TAG", "onCreate:" + power);
|
||||
if (power < 5 || power > 30) return;
|
||||
dialogCall.returnData(power);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
public void show(int power){
|
||||
super.show();
|
||||
editText.setText(power+"");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/dialog_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/tip_set_power"
|
||||
android:textSize="20sp" />
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#e1e1e1"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dialog_text"
|
||||
style="@style/text_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:layout_margin="30dp"
|
||||
android:inputType="number"
|
||||
android:hint="5~30"
|
||||
android:background="@drawable/san_text" />
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#e1e1e1"/>
|
||||
<TextView
|
||||
android:id="@+id/dialog1_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:text="@string/configuration_save"
|
||||
android:textSize="18sp"
|
||||
android:gravity="center"
|
||||
android:letterSpacing="0.5"
|
||||
android:textColor="@color/design_default_color_secondary"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue