小编Sag*_*tus的帖子

使用Jetpack Compose ModalBottomSheet:在初始化之前读取偏移量

我正在使用ModalBottomSheet并且必须State hoisting使用它的祖先组件。

class MainActivity : ComponentActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
      Demo4Theme {
        // A surface container using the 'background' color from the theme
        Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
          ArticleScreen()
        }
      }
    }
  }
}
@Stable
class ArticleState(
  val orderModalState: SageSheetState,
  val filterModalState: DrawerState
)

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun rememberSageSheetState(
  state: SageSheetState = SageSheetState(
    coroutineScope = rememberCoroutineScope(), sheetState = rememberSheetState()
  )): SageSheetState {
  return remember { state }
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-jetpack-compose

12
推荐指数
1
解决办法
3981
查看次数

Gradle 找不到 protobuf 生成的类(Android DataStore)

我是参考文档引入了依赖

implementation "androidx.datastore:datastore:1.0.0"
Run Code Online (Sandbox Code Playgroud)

然后定义架构app/src/main/proto/.proto

syntax = "proto3";

option java_package = "com.freedom.android.config.work";
option java_multiple_files = true;

message WorkItemVO {
  
  bool enabled = 1;
  
  string title = 2;
  
  string repeat_interval = 3;
  string repeat_interval_timeUnit = 4;
  
  string last_update_time = 5;
  string last_update_result = 6;
}
Run Code Online (Sandbox Code Playgroud)

之后app build,却build/generated/source/proto/没有生成WorkItemVOclass文件。

你能告诉我我错过了什么吗?

android-studio android-jetpack-datastore

3
推荐指数
1
解决办法
428
查看次数

kotlin 单例对象会被 JVM 回收吗?

kotlin关键字对象创建的单例类会被JVM回收吗?

object MySingleton
Run Code Online (Sandbox Code Playgroud)

如果MySingleton从未使用过,那么在应用程序运行时它是否会继续占用内存?

jvm kotlin

-1
推荐指数
1
解决办法
127
查看次数