如果某个字符串以 in 中的字符结尾,arrayOf(X, Y, Z)我想将其替换为 new char A。我不知道该怎么做,我尝试过的一切都不起作用。
我有一个radioGroup

在哪里onChangeListener更改主题
我想实现这一点:
当您检查黑暗无线电时,动画将从黑暗无线电的位置开始
如果您检查光,它将从光开始等
如何在andoid应用程序中制作这种动画?
我的完整主题更改代码:
public void chooseTheme(MenuItem item) {
final AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
final View mView = getLayoutInflater().inflate(R.layout.dialog_theme,null);
Button btn_cancel = mView.findViewById(R.id.btn_cancel);
Button btn_okay = mView.findViewById(R.id.btn_okay);
alert.setView(mView);
final AlertDialog alertDialog = alert.create();
alertDialog.setCanceledOnTouchOutside(false);
final RadioGroup themeGroup = mView.findViewById(R.id.themeGroup);
btn_cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialog.dismiss();
}
});
themeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@SuppressLint("NonConstantResourceId")
@Override
public void onCheckedChanged(RadioGroup themeGroup, int i) {
switch(i) {
case R.id.radioLight:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
setTheme(R.style.AppTheme);
Toast.makeText(getApplicationContext(),"Light mode",Toast.LENGTH_LONG).show(); …Run Code Online (Sandbox Code Playgroud) 我陷入了困境,我不知道如何在 MarginLayout 中将 px 转换为 dp
所以这是我的主要 MarginLayout 设置方法
public static void setMargins (View v, int l, int t, int r, int b) {
if (v.getLayoutParams() instanceof LinearLayout.MarginLayoutParams) {
LinearLayout.MarginLayoutParams p = (LinearLayout.MarginLayoutParams) v.getLayoutParams();
p.setMargins(l, t, r, b);
v.requestLayout();
}
}
Run Code Online (Sandbox Code Playgroud)
这是在元素更改其 marginLayout 的点击侦听器上
ArrowUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!Switch){
setMargins(AdditionalOperations, 0, 0, 0, 800);
Switch = true;
}
else{
setMargins(AdditionalOperations, 0, 0, 0, 715);
Switch = false;
}
}
});
Run Code Online (Sandbox Code Playgroud)
我的目标是将像素转换为 Dp,并以 DP 值(而不是 px)作为边距。我真的陷入了困境,无法理解
val myDict : HashMap<Int, String> = hashMapOf( 0 to "zero", 1 to "one", 2 to "two" )
Run Code Online (Sandbox Code Playgroud)
我必须找到 myDict HashMap 的最大 Int 键值。像这样的东西:
myDict.getMaxKey() // should be 2
Run Code Online (Sandbox Code Playgroud)