当前位置: 首页 > news >正文

上海奉贤做网站教务系统管理系统

上海奉贤做网站,教务系统管理系统,网站首页不被收录,豆瓣 wordpress【Android Compose】ListView效果 1、Column、Row 和 Box2、LazyColumn和LazyRow3、Compose 中的状态4、ListView效果5、android-compose-codelabs Jetpack Compose 使用入门 Jetpack Compose 教程 Jetpack Compose 1、Column、Row 和 Box Compose 中的三个基本标准布局元素是 …

【Android Compose】ListView效果

  • 1、Column、Row 和 Box
  • 2、LazyColumn和LazyRow
  • 3、Compose 中的状态
  • 4、ListView效果
  • 5、android-compose-codelabs

Jetpack Compose 使用入门
Jetpack Compose 教程
Jetpack Compose


1、Column、Row 和 Box

Compose 中的三个基本标准布局元素是 Column、Row 和 Box 可组合项。

在这里插入图片描述

2、LazyColumn和LazyRow

androidx.compose.foundation.lazy.LazyColumn
androidx.compose.foundation.lazy.LazyRow
androidx.compose.foundation.lazy.items

3、Compose 中的状态

7. Compose 中的状态

  • mutableStateOf 函数,该函数可让 Compose 重组读取该 State 的函数
  • 如需在重组后保留状态,请使用 remember 记住可变状态
  • onClick 它不接受值,而接受函数
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
// ...@Composable
fun Greeting(...) {val expanded = remember { mutableStateOf(false) }ElevatedButton(onClick = { expanded.value = !expanded.value },) {Text(if (expanded.value) "Show less" else "Show more")}
}

4、ListView效果

https://gitee.com/xhbruce/XhAndroidDemo
在这里插入图片描述

package com.xhbruce.xhandroiddemoimport Message
import SampleData
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.ElevatedButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.view.WindowCompat
import com.xhbruce.xhandroiddemo.ui.theme.XhAndroidDemoThemeclass MainActivity : ComponentActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)enableEdgeToEdge()WindowCompat.setDecorFitsSystemWindows(window, true)setContent {XhAndroidDemoTheme {//PreviewGreeting()Conversation(SampleData.conversationSample)}}}
}@Composable
fun MessageCard(msg: Message) {// We keep track if the message is expanded or not in this// variablevar isExpanded by remember { mutableStateOf(false) }// surfaceColor will be updated gradually from one color to the otherval surfaceColor by animateColorAsState(if (isExpanded)MaterialTheme.colorScheme.primaryelseMaterialTheme.colorScheme.surface,)// We toggle the isExpanded variable when we click on this ColumnColumn(modifier = Modifier.clickable { isExpanded = !isExpanded }.fillMaxSize()) {Text(text = msg.author,color = MaterialTheme.colorScheme.secondary,style = MaterialTheme.typography.titleSmall)Spacer(modifier = Modifier.height(4.dp))Surface(shape = MaterialTheme.shapes.medium,shadowElevation = 1.dp,// surfaceColor color will be changing gradually from primary to surfacecolor = surfaceColor,// animateContentSize will change the Surface size graduallymodifier = Modifier.animateContentSize().padding(1.dp)) {Text(text = msg.body,modifier = Modifier.padding(all = 4.dp),// If the message is expanded, we display all its content// otherwise we only display the first linemaxLines = if (isExpanded) Int.MAX_VALUE else 1,style = MaterialTheme.typography.bodyMedium)}}
}@Composable
fun Conversation(messages: List<Message>) {LazyColumn {items(messages) { message ->MessageCard(message)}}
}@Preview
@Composable
fun PreviewMessageCard() {XhAndroidDemoTheme {Conversation(SampleData.conversationSample)}
}@Preview
@Composable
fun PreviewGreeting() {val expanded = remember { mutableStateOf(false) }ElevatedButton(onClick = { expanded.value = !expanded.value },) {Text(if (expanded.value) "Show less" else "Show more")}
}

5、android-compose-codelabs

git clone https://github.com/googlecodelabs/android-compose-codelabs.git

在这里插入图片描述

http://www.yayakq.cn/news/692594/

相关文章:

  • 做好网站如何发布有什么超好用的做简历的网站
  • 网站制作介绍wordpress调用文章tag
  • 网站的根目录中tug wordpress
  • 做易买网网站项目心得体会韩国教做发饰的网站
  • 不想花钱怎么做网站哪家做网站做得好
  • 曲靖企业网站建设福州+网站建设+医疗
  • 做网站得花多钱深圳罗湖做网站58
  • 买了域名之后如何做网站成品网站前台源码
  • 杭州h5建站在线咨询长垣做网站
  • 网站建设用户调查报告动态ip可以做网站吗
  • 珠海市官网网站建设价格网站标题几个字合适
  • 网站建设咨询有客诚信网站建设咨询德阳网站优化
  • 网站建设费长期待摊费用企业网站的常见服务
  • 做公众号推送的网站网站制作外包价格
  • 西安集团网站建设中国网站建设排名
  • 唐山市住房和城乡建设局官方网站外贸网站推广哪个比较好
  • 免费的设计网站有哪些如何用凡科网建立一个网站
  • 网站建设的缺点个人ip打造范文
  • 做实验流程图的网站济南网站建设招标
  • 广州学生做网站英文网站建设成都
  • 网站建设以后就业方向如何加强企业网站建设 论文
  • wordpress网站后台要怎么登陆asp提高网站安全性的措施
  • wordpress网站描述插件互联网行业排行榜
  • 中南建设的网站响应式网站开发流行吗
  • 小规模公司做网站成本是什么wordpress怎么实现注册功能
  • 给微商做网站可以申请做cpa广告的网站
  • 做关于什么内容的网站数字媒体艺术
  • qq邮箱做网站专业建设网站的企业
  • 劳务公司网站建设学做网站必须php吗
  • 外贸网站如何推广泰州市建设工程质量监督站网站