492 questions
1
vote
1
answer
22
views
Cannot dynamically adjust z-index of ConstraintLayout children when using a camera stream & map
In my layout i display a stream widget (the WidgetFPV one) which contains a surface onto which a camera stream is projected via DJI'S MSDK5 sdk. I also have a card mapCard which hosts a MapBox map ...
0
votes
0
answers
95
views
Fragment’s View Not Visible After Returning from Background in Jetpack Compose App
Question:
I’m developing an Android app using Jetpack Compose and Fragments. I’m experiencing an issue where the view inside a Fragment is not visible when the app returns from the background under ...
1
vote
1
answer
67
views
Why do we provide inflater argument into BindingInflater lambda?
I am new in Android development and can not fully understand this template for ViewBinding using abstract class. More precisely, I don’t understand why we prode inflater argument into bindingInflater ...
0
votes
1
answer
65
views
Android view binding for alternate layout
In one project I was working, has 2 layouts for a custom view. For 220 screenWidthDp has different layout. View ids are same in both layouts. Currently layouts are loaded like this
Configuration ...
2
votes
1
answer
144
views
How to resolve SpotBugs warning about exposing internal representation with Android Data Binding?
I'm working on an Android project using data binding, and I've encountered a warning in the SpotBugs violation report that I'm not sure how to address. Here's the setup:
<?xml version="1.0&...
1
vote
1
answer
2k
views
In android studio(Kotlin), why ViewBinding and setOnApplyWindowInsetsListener conflicts?
When I use codes generated by android studio automatically and ViewBinding together, the programme will crash.
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
...
3
votes
2
answers
83
views
How to use ViewBindings for mutiple layouts
I'm migrating from kotlinx.android.synthetic to ViewBindings.
I have two layouts(for phones and tablets) with the same set of ids:
class GameActivity: AppCompatActivity() {
lateinit var binding: ...
0
votes
1
answer
59
views
How to display result depending on the radio button choice?
I'm working on an Android Studio activity in which I have to calculate area and perimeter. I used intent to pass and access variables that will be used in another activity where the computations will ...
0
votes
0
answers
61
views
How to pass a double value of an editText to another activity in android?
I'm working on an activity in android studio in which I need to compute area and perimeter. I used intent and view Binding to access and pass the value of the user input in the edit Text to another ...
0
votes
1
answer
854
views
How to fix runtime error in Android studio
I am working on a project in Android Studio when I ran into an issue where it kept crashing when I attempted to run it on a real device. It worked perfectly fine at first, however as I used ...
0
votes
1
answer
157
views
How to properly create a parent fragment with ViewBinding?
I have around 15 fragments that mostly use the same code, I also have created a BaseFragment for ViewBinding that works, so that I don't need to write that part every time.
However there are other ...
0
votes
1
answer
45
views
I couldnt genarate view binding in kotlin [closed]
enter image description here
When I try genarate view binding for kotlin, its giving red line on inflate and I cannot run project.
package com.example.wiewbinding
import androidx.appcompat.app....
0
votes
2
answers
88
views
My RecyclerView is not showing any data Android Studio(Kotlin, ViewBinding)
I am creating a weather app in which the recycler view is suppose to show today's forecast but is not showing anything. I am also not getting any kind of error in my code.
I have tried everything I ...
0
votes
2
answers
308
views
How to create a RadioButton custom view?
I've tried many tutorials and solutions on internet but couldn't make mine work.
Basically I want a layout like this to work as 7 RadioButtons:
I have my CustomRadioButton class that I want it to ...
1
vote
1
answer
83
views
Android How to Reference EditText in Activity using ViewBinding in Fragment
I have an issue with ViewBinding in a Fragment for an EditText line in the Activity. The Fragment launches a dialog to ask a user if they want to clear the EditText line. The EditText line is set up ...
-1
votes
1
answer
332
views
How to use View Binding insted of butterknife?
I am updating an app. In the new program, I intend to use View Binding because butterknife library does not work. My codes are as follows. How do I use the new method?
The previous code uses the ...
0
votes
1
answer
56
views
Why does changing the text view in the internal layout with viewbinding not reflect the text in the UI?
I want to change text of TextView which is in inner ConstraintLayout.
When I try binding.lyricViewTitle.text = it.title, binding.lyricViewTitle text is changed(I check with Debug), but lyricViewTitle ...
0
votes
1
answer
52
views
update include tag data when app theme changed (recreating Activity)
I used multiple include tags in a xml layout like this:
<include
android:id="@+id/firstView"
layout="@layout/layout_edit_text"
android:layout_width="...
5
votes
2
answers
664
views
Android use viewbinding, without 'binding.' keyword within class globally
After enabling viewbinding using:
android {
...
buildFeatures {
viewBinding = true
}
}
We can use ViewBinding, the problem is that we need to use binding. prefix before accesing ...
1
vote
0
answers
36
views
Is ViewBinding set up correctly?
My project is not finding the reference to the 1st monster01.
binding.monster01.setOnClickListener { viewMonsterImage(R.drawable.monster01) }
Here is the whole section:
class MainActivity : ...
2
votes
0
answers
553
views
Fatal Exception: java.lang.IllegalArgumentException: No view found for id In AndroidViewBinding Jetpack Compose
I am loading a fragment inside Jetpack Compose AndroidViewBinding as shown below,
val fragmentManager = (LocalContext.current as? FragmentActivity)?.supportFragmentManager
AndroidViewBinding(
...
1
vote
0
answers
39
views
SafeArgs and View Binding properties visibility
This question could be applied to many other cases.
In a android fragment class implemented with Kotlin, it's common to see this using View Binding and SafeArgs:
class MyFragment: Fragment(){
var ...
0
votes
1
answer
513
views
Create a Base Activity with ViewBinding for multiple activities with same views
i have twenty different activities with the same MaterialTextView (same name in all activities)
in all activities (in the onCreate event), i initialize the textview with the same text:
textview.text = ...
0
votes
1
answer
96
views
ViewBinding not working with Intent.putExtra
I am new to view binding. If I use findViewById and pass the data string data using intent's putExtra, everything is working fine. But it is not working with view Binding.
class MainActivity : ...
0
votes
1
answer
99
views
How to set null for generics in Kotlin
In my application I used ViewBinding for access to views and for this I create Base Fragment and write below codes.
In onDestroy method I want null the views but show me error.
My BaseFragment codes:...
0
votes
1
answer
107
views
Data binding not working for FragmentA after returning from FragmentB
My app has two fragments: HomeFragment and StatusFragment. HomeFragment binds some connection info to the UI. Info is obtained from broadcast receiver. At the beginning, data binding works in ...
0
votes
1
answer
40
views
ViewBinding with dynamically added content
I have base activity implementing some features for every screen of my app. Every child activity then overrides method with its XML layout.
BaseActivity
@Override
protected void onCreate(Bundle ...
0
votes
2
answers
89
views
ViewBinding with CardView Dialog Box not displaying width correctly
I'm having to migrate to ViewBinding in my Android app to comply with the latest target versions. I'm really struggling to get a dialog box created using CardView to display correctly.
The below is ...
-1
votes
1
answer
47
views
RecyclerView doesn't appear on the screen
I make an app which use API and should show some basic data (exchange rates) on the screen.
But elements of recyclerView doesn't appear on the screen. I can see only textview.
Trying to find a problem ...
0
votes
0
answers
71
views
NullPointerException in getViewBinding
I have a fragment that uses viewbinding through eventhandlers. The eventhandlers are setup and taken down in onResume() and onPause(). In rare cases accessing the view through events results in a ...
1
vote
1
answer
2k
views
I'm unable to set the viewBinding in Android Studio
I'm stucked like 5 days in this problem!
I'm unable to bind the view using viewBinding clause in Android Studio, I believe the problem is in "build.gradle" file.
Initially, I tried to build ...
0
votes
2
answers
1k
views
How to navigate to another activity based on viewmodel's logic, with view binding / MVVM?
I have:
MainActivity
MainFragment
MainViewModel
SecondActivity
ThirdActivity
I have a button in fragment_main.xml. I can easily pass it android:onClick="navigate" and have the function ...
0
votes
1
answer
21
views
Followed tutorial but can't get MainActivityBinding class generated for ViewBinding
Following the exact documentation but can't figure out why it's not working...
https://developer.android.com/topic/libraries/view-binding
The class is never generated for my MainActivity
activity_main....
1
vote
1
answer
228
views
Android: custom view's addView() causes null pointer exception
I've overrided addView(child: View?) in my custom view and inflating layout causes NullPointerException.
My code:
TestView.kt
package com.example.testandroid
import android.content.Context
import ...
0
votes
0
answers
21
views
How to propertly include layout in to the main layout to store all data in one data binding?
I have three different blocks in my application. I'm trying to make a data binding.
Right now, I'm trying to figure out how to bind at least two layouts together.
This is part of my layout that I have ...
0
votes
0
answers
53
views
How to implement Android CustomButton by extends AppCompatButton
I have to implement custom button looks like next picture
and this,
button.xml (layout resource)
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget....
0
votes
1
answer
93
views
i was trying to make a back button between two screens by toolbar but it shows error
i am trying to make a map based app where i used a floating bar action button to change through one window to another i wanted another back button so i used toolbar which i mentioned in my xml ...
0
votes
1
answer
44
views
NullPointerException when inflating an item view of a RecyclerView through viewBinding
I have a multi module application. In the module ui I have the item I want to show in the RecyclerView, in the module checkout there is the fragment that contains the RecyclerView.
CheckoutFragment
...
1
vote
1
answer
975
views
Jetpack Compose + AndroidViewBinding backpress will close the app
I have a navhostfragment inside an AndroidViewBinding in a Composable function. However, when I press the back button on the phone, the app closes. How can I avoid this and just go up in the ...
0
votes
2
answers
1k
views
Unable to replace CustomToolbar with ActionBar in Kotlin
I Created a Custom Toolbar and placed it in activity, but I got this error :
java.lang.IllegalStateException: Activity com.example.citiesdistance.feature.main.MainActivity@3a04806 does not have an ...
0
votes
1
answer
126
views
Refactoring RecyclerView with multi ViewHolder from ButterKnife using ViewBinding
Wanting to switch to version 8.0 of AGP for my Android project I had to refactor a lot of java classes where the developer before me used ButterKnife to bind variables to layout elements. The last ...
0
votes
1
answer
177
views
Android studio kotlin viewBinding caching problems class name
I renamed a class, then gradled the ability to enable viewBinding.
When I import the class, it doesn't find the renamed class, but the one with the old class name.
Can you give me a hand?
...
1
vote
1
answer
126
views
Android-Databinding TextField with Regex
I'm using M3 TextField with XML data binding. I want to send input to ViewModel and if is valid, text field's text should equal to this input, else should no change on TextField's text.
Here is XML ...
0
votes
1
answer
102
views
RecyclerView doesn't show items until scrolling in kotlin
I have a RecyclerView that shows a list with livedata.
RecyclerView adapter is prepared with viewBinding.
My problem is that the RecyclerView does not show the items, but when I scroll the ...
0
votes
1
answer
313
views
How do I fix this type conversion problem that is causing my app to crash?
I'm new to Android development, so I just got the hang of Gradle and just ran my app for the first time. However, I have no idea why it keeps crashing because I don't really know how to read the error ...
0
votes
3
answers
2k
views
Common way to handle form state in StateFlow in Android
I am trying to implement an form screen with many EditTexts, Switches, etc. I have a fragment with viewBinding and viewModel that holds a StateFlow "formData". Every field in UI have its own ...
0
votes
0
answers
2k
views
ViewBinding - no candidates found for method call viewBinding
I have a problem with using the feature 'viewBinding' - at first look everything seems to work, however when I took a closer look on my build.gradle file I could see that in fact
buildFeatures {
...
2
votes
1
answer
2k
views
Getting Error inflating class fragment error while using view binding in fragments
Since Kotlin 1.8 made view binding compulsory so I implemented it in main activity and fragment. But I am getting error inflating the class fragment
Here is the main activity class. I think there is ...
0
votes
2
answers
250
views
Kotlin -How to call finish() in a RecyclerViewAdapter using Binding (not context)
I need to finish() the Activity that the RecyclerView is in when an item/row is tapped.
I looked this up but most of the answers referred to the old way of doing things when using context and (context ...
0
votes
1
answer
52
views
How to handle click event in viewbinding
I have a layout with view pager and tabs layout.
Viewpager contains two layouts for fragments fragmentpage1 and fragmentpage2.
In fragmentpage1.xml i have an imageview who's id is "myimgbtn&...