增加 设置功能

fengshen
wanghao 2 months ago
parent 1d216c6e86
commit c2b4aa59e7

@ -23,6 +23,7 @@ public class HomeActivity extends BaseActivity {
RadioButton button1 = this.findViewById(R.id.home_1); RadioButton button1 = this.findViewById(R.id.home_1);
RadioButton button2 = this.findViewById(R.id.home_2); RadioButton button2 = this.findViewById(R.id.home_2);
RadioButton button1_1 = this.findViewById(R.id.home_1_1); RadioButton button1_1 = this.findViewById(R.id.home_1_1);
RadioButton button4 = this.findViewById(R.id.home_4);
Intent intent = new Intent(this, ShuangqianActivity.class); Intent intent = new Intent(this, ShuangqianActivity.class);
button1.setOnClickListener(v -> { button1.setOnClickListener(v -> {
intent.putExtra("type",true); intent.putExtra("type",true);
@ -36,7 +37,9 @@ public class HomeActivity extends BaseActivity {
button2.setOnClickListener(v -> { button2.setOnClickListener(v -> {
startActivity(new Intent(this, ShuangqianActivity2.class)); startActivity(new Intent(this, ShuangqianActivity2.class));
}); });
button4.setOnClickListener(v -> {
startActivity(new Intent(this, SettingsActivity.class));
});
} }
@Override @Override

@ -10,23 +10,8 @@ public class SettingsActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.settings, new SettingsFragment())
.commit();
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
} }
public static class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.root_preferences, rootKey);
}
}
} }

@ -51,9 +51,7 @@ public class BaseActivity extends AppCompatActivity {
uhfrManager.setPower(30, 30); uhfrManager.setPower(30, 30);
accesspwd = Tools.HexString2Bytes("00000000"); accesspwd = Tools.HexString2Bytes("00000000");
music = MediaPlayer.create(this, com.example.writeepc.R.raw.msg); music = MediaPlayer.create(this, com.example.writeepc.R.raw.msg);
// int[] power = uhfrManager.getPower();
// Log.e("TAG", "initUHFRManager:" + power[0]);
// Log.e("TAG", "initUHFRManager:" + power[1]);
} }
public void initUHFRManager1() { public void initUHFRManager1() {
@ -62,9 +60,7 @@ public class BaseActivity extends AppCompatActivity {
uhfrManager.setPower(22, 22); uhfrManager.setPower(22, 22);
accesspwd = Tools.HexString2Bytes("00000000"); accesspwd = Tools.HexString2Bytes("00000000");
music = MediaPlayer.create(this, com.example.writeepc.R.raw.msg); music = MediaPlayer.create(this, com.example.writeepc.R.raw.msg);
// int[] power = uhfrManager.getPower();
// Log.e("TAG", "initUHFRManager:" + power[0]);
// Log.e("TAG", "initUHFRManager:" + power[1]);
} }

@ -70,13 +70,15 @@
android:textSize="20sp" /> android:textSize="20sp" />
<RadioButton <RadioButton
android:id="@+id/home_4"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:button="@null" android:button="@null"
android:drawableTop="@mipmap/home_setting"
android:drawablePadding="10dp" android:drawablePadding="10dp"
android:gravity="center" android:gravity="center"
android:text="设置"
android:textSize="20sp" /> android:textSize="20sp" />
</RadioGroup> </RadioGroup>
@ -100,17 +102,7 @@
android:text="轮胎信息查询" android:text="轮胎信息查询"
android:textSize="20sp" /> android:textSize="20sp" />
<RadioButton
android:id="@+id/home_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@mipmap/home_setting"
android:drawablePadding="10dp"
android:gravity="center"
android:text="设置"
android:textSize="20sp" />
</RadioGroup> </RadioGroup>

@ -1,9 +1,74 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_gravity="center"
android:background="#6750A4"
android:letterSpacing="1"
android:text="设置"
android:textColor="@color/white"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="45dp"
<FrameLayout android:layout_marginTop="20dp"
android:id="@+id/settings"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="绑定功率:" />
<Spinner
android:id="@+id/select_power_binding"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="45dp"
android:layout_gravity="center"
android:entries="@array/power"
android:textAlignment="center"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="追溯功率:" />
<Spinner
android:id="@+id/select_power_"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:entries="@array/power"
android:textAlignment="center"
/>
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="setPower"
android:text="设置功率" />
</LinearLayout> </LinearLayout>
Loading…
Cancel
Save