我有以下活动
class MainActivity : AppCompatActivity() {
private lateinit var drawerLayout: androidx.drawerlayout.widget.DrawerLayout
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main_activity)
drawerLayout = drawer_layout
val navController = Navigation.findNavController(this, R.id.fragment_main_navHost)
setSupportActionBar(toolbar)
NavigationUI.setupActionBarWithNavController(this, navController, drawerLayout)
navView_main.setupWithNavController(navController)
}
override fun onSupportNavigateUp(): Boolean {
return NavigationUI.navigateUp(drawerLayout,
Navigation.findNavController(this, R.id.fragment_main_navHost))
}
override fun onBackPressed() {
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START)
} else {
super.onBackPressed()
}
}
Run Code Online (Sandbox Code Playgroud)
你可以看到它与导航图相关联,我正在使用导航抽屉.当我浏览抽屉中的项目时,我想保留汉堡图标,只有当我点击片段或弹出窗口中的项目时才将其更改为上/后按钮,并确保系统的行为反映了什么用户期望基于显示的图标.那可能吗
android kotlin navigation-drawer android-jetpack android-architecture-navigation
我有一个扩展的类BaseObservable,这个类包含double值
这是一个例子:
public class BindedValue extends BaseObservable {
public double value;
public TextWatcher setValue = new TextWatcherAdapter(){
@Override
public void afterTextChanged(Editable s) {
value = Double.parseDouble(s.toString());
}
};
}
Run Code Online (Sandbox Code Playgroud)
然后我得到了xml
<data class="net.example.util.Value">
<variable
name="BindedValue"
type="net.makereal.makerealmaquette.domain.BindedValue"/>
Run Code Online (Sandbox Code Playgroud)
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="Value"
android:addTextChangedListener="@{BindedValue.setValue}"
android:inputType="numberDecimal"
android:text="@{BindedValue.value}"/>
Run Code Online (Sandbox Code Playgroud)
当我尝试运行或构建应用程序时,我收到此错误:
Cannot find the setter for attribute 'android:text' with parameter type double on android.widget.EditText.
Run Code Online (Sandbox Code Playgroud)
但是,当我将类型更改为int时,应用程序构建没有问题.
有没有办法绑定双?
我在协调器布局内使用底部应用栏。其余内容来自片段。片段内容被底部应用栏覆盖
因为我使用的是 bottomAppBar,所以它必须在 CoordinatorLayout 内,并且所有孩子也必须在其中。BottomAppBar 上方的所有布局都应该填充提醒的空间,但如果我这样做,底部的视图就会被覆盖。如何确保视图不与 BottomAppBar 重叠
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawerLayout_main"
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=".main.MainActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="0dp"
android:layout_height="wrap_content">
</androidx.constraintlayout.widget.ConstraintLayout>
<fragment
android:id="@+id/fragment_main_navHost"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
android:layout_gravity="top"
app:navGraph="@navigation/nav_graph"/>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:fabAlignmentMode="end"
app:fabCradleMargin="4dp"
app:hideOnScroll="true"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navView_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header_layout"
app:menu="@menu/main_navigation"/>
Run Code Online (Sandbox Code Playgroud)
我需要的是确保替换片段的任何内容都不应被底部应用栏覆盖,并且它应该使用底部应用栏未使用的所有空白区域。我是另一个世界,内容应该在它上面,同时使用其余的空白区域并且仍然在协调器布局内。
android material-design android-coordinatorlayout android-bottomappbar
我正在尝试使用intent-filter ACTION_PACKAGE_FIRST_LAUNCH使应用程序在首次启动时执行某些任务,但是它没有被广播接收器捕获我的清单
<receiver android:name=".reminder.ReminderActionReceiver" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_FIRST_LAUNCH" />
<action android:name="android.intent.action.PACKAGE_DATA_CLEARED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
这是我的广播接收器实现
this.context = context;
String mAction = intent.getAction();
Log.i("r", mAction);
if (mAction == Intent.ACTION_PACKAGE_DATA_CLEARED) {
} else if (mAction == Intent.ACTION_PACKAGE_FIRST_LAUNCH) {
}
Run Code Online (Sandbox Code Playgroud)
如何在应用程序首次启动时启动它?
我有一个用 swift 编写的 ios 应用程序,我正在使用 RealmSwift 来保存我的数据,在升级到最新版本之前,该应用程序运行良好,但在升级到 realmswift 0.97 后,每次我尝试运行该应用程序时,它都开始出现此问题
> Pods/Realm/include/realm/string_data.hpp:33:10:
> 'realm/util/features.h' file not found
Pods/Realm/Realm/ObjectStore/object_schema.cpp:19:10: In file included from Pods/Realm/Realm/ObjectStore/object_schema.cpp:19:
Pods/Realm/include/realm/object_schema.hpp:22:10: In file included from Pods/Realm/include/realm/object_schema.hpp:22:
Run Code Online (Sandbox Code Playgroud) android ×4
android-architecture-navigation ×1
intentfilter ×1
ios ×1
java ×1
kotlin ×1
realm ×1
swift ×1