我在Gruda Linux上使用compose 3和海豚Android Studio。全部更新!
我有一个名为feed的@Composable
函数,它只有一个FilledTonalButton
。
对于FilledTonalButton
的内容我给出icons.rounded.Add
每当我建造的时候
e: /home/kumar-p/Desktop/AndroidStudio/<app_name>/app/src/main/java/com/f/rateme/MainActivity.kt: (95, 27): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public val Icons.Rounded.Add: ImageVector defined in androidx.compose.material.icons.rounded
<app_name>=我的应用程序名称,由于保密原因已删除。
然而,当我用Text()
替换Icon()
时,它工作了!
我的相依性:
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.compose.material3:material3:1.0.0-alpha02'
implementation "androidx.compose.material:material-icons-extended:$compose_version"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
我在MainActivity.kt
上的导入
package com.<example>.rateme // <example> = my company name
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.*
import androidx.compose.material.icons.rounded.Add
import androidx.compose.material3.*
//import androidx.compose.material.icons.Icons
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.<example>.<app_name>.ui.theme.AppTheme // <example> = my company name, <app_name> = name of curent app
功能:
@Composable
fun feed(page: String): String {
FilledTonalButton(
onClick = {/*TODO: Add onClick for feed - New Post*/},
enabled = true) {
Icon(
imageVector = Add,
"New Post"
)
}
return page // TODO: implement the changes of page variable
}
如果你发现任何错字,请更新它或告诉我修复。
PS:这是我第一次来这里,我对Android开发和Kotlin几乎没有任何经验。我开发了终端应用程序,用Python、C++、C进行了ML工作。所以我可能需要更多的信息来解释。我一周前才开始学习Android开发。
编辑:你可以问我任何更多的信息。
平安
1条答案
按热度按时间hc2pp10m1#
只需像这样指定实际的imageVector,
但是你仍然会得到歧义错误。因为根据你的帖子看起来你想使用material3,所以删除这个导入
或者如果您仍然希望同时使用它们,那么您必须在使用时声明它们的完全限定名,