正如标题所说,我正在尝试将自定义 image.png 添加到我的底部导航栏,但我找不到确切的方法。
我试过:
矢量资产和图像资产不显示我的 image.png
为我的图像创建一个选择器 xml 并将其添加到我的导航菜单中,但它只显示一个灰色方块而不是图像
我认为解决方案一定很简单,但在此论坛上找不到任何相关内容。
提前致谢。
编辑:
底部导航.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/airplane"
android:icon="@drawable/vegetables"
android:title="Vegetable"
/>
</menu>
Run Code Online (Sandbox Code Playgroud)
蔬菜.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/veg" android:state_checked="false"/>
<item android:drawable="@drawable/veg1" android:state_checked="true" />
</selector>
Run Code Online (Sandbox Code Playgroud)
活动_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/bottom_navigation"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:background="?android:attr/windowBackground"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud) 我正在使用登录/注册应用程序进行培训,因为我是一个初学者,除了一个小问题之外,其他所有功能都可以正常工作,但是我不知道如何解决它,我尝试了搜索,但是在这里找不到任何内容我的数据库
fun userPresent (user: String,pass: String):Boolean {
val db = writableDatabase
val query = "select * from $TABLE_NAME where username = $user and password = $pass"
val cursor = db.rawQuery(query,null)
if (cursor.count <= 0) {
cursor.close()
return false }
cursor.close()
return true }
Run Code Online (Sandbox Code Playgroud)
mainactivity.kt
if (database.userPresent(user = username,pass = password)) {
intent.putExtra("text", "Welcome , $username $password")
startActivity(intent)
Toast.makeText(this,"Logged In Successfully",Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this,"Wrong Username/Password",Toast.LENGTH_SHORT).show()
}
Run Code Online (Sandbox Code Playgroud)
我的logCat错误
android.database.sqlite.SQLiteException: no such column: ss (code 1 SQLITE_ERROR): , while compiling: select * …Run Code Online (Sandbox Code Playgroud)