Questions tagged onclicklistener

Explore the latest questions and answers asked by our top developers.

Android: Disable button, process code and enable button not working

I am developing an android app where I have a Floating Action Button (or Button). Upon clicking this button, it should first disable itself, followed by a heavy task and then enable itself. The idea is, the user not be able to click on the button until unless the task is ongoing. Current code looks […]

How to handle multiple card views / buttons on a fragment

I have multiple card views in my Main Fragment that go to different fragments within the app usin onClickListener functionality. However, when the cardviews are selected the fragment that shows is always the last replaced. Ex: In main activity all the card views, when selected, show the affirmations fragment. No matter if they have been […]

Opening an activity layout within a fragment with multiple onclicks that take you to another layout activity

I’m really new to mobile development, I’m trying to open new activity layouts within a fragment with the use of an Image View with on click events, but I have multiple image views but I can only get one image view on click to work, I don’t know how to apply this to the rest […]

By raf117
Published
Categorized as android, android-studio, java, onclicklistener, switch-statement

Can you add sound to cardview with OnClickListener?

I’m wondering if I can add sound to cardview with OnClickListener? I’m trying to make a ‘kids learning app’ for color that works like this; when you tap or press on the cardview, the sound (for example, blue) will come out. Is it possible? I searched everywhere for this, but I don’t seem to find […]

RecyclerView OnClickListener Best Practice – MVVM

I tried to create onClickListener to my recyclerview like I would do without MVVM pattern but it wasn’t working. After I tried different ways with no success I hope I will find my answer here. Thank you ! This is my RecyclerView Adapter: class MainRecyclerViewAdapter(var moviesList: List<Movie>) : RecyclerView.Adapter<MainRecyclerViewAdapter.MovieHolder>() { inner class MovieHolder(var itemView : […]

Force TextView refresh in Kotlin function

I’ve created a very simple dice rolling app, and instead of the number appearing when the onClickListener is active, I’d like to refresh the text view with "rolling…" and then followed by the dice result. I’m using the following code: class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val rollButton: Button […]

By James Hart
Published
Categorized as android, android-view-invalidate, kotlin, onclicklistener

How to prevent button double click

I have a button in my activity. When the user clicks on the button, progress is shown and a request is sent to the server, after receiving a response to the request, the progress is hided and the next activity is opened. However, if the user has time to press the button several times, two […]

By testivanivan
Published
Categorized as android, android-button, double-click, onclicklistener

Kotlin: Buttons inside a fragment needed to be clicked twice before starting the activity. How can I start the activity with only one click?

newbie here! I’m having a hard time learning the life cycle of fragments and I’m stuck in this problem. If I run this on the emu, the fragment is showing on the activity but the button inside the fragment needs to be clicked twice to run the destination activity. Here is my FragmentSetting.kt: class FragmentSetting […]

View OnClickListener doesn’t work and in gray cast

I have a Recycler Adapter and I am trying to display the next layout after clicking on the card in my recycler adapter. But my OnClickListener doesn’t work and it is still in gray font. The final int position I put in the function appears as an error too. How can I fix that? RecyclerViewAdapter […]

How do I overlap views and add onclick listeners in Android

I want to create a user-interface in Android studio and also add invisible layouts in the background. I want the background layouts to trigger onclick events whenever a UI component above it is clicked. <RelativeLayout 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"> <TextView android:id="@+id/texts" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Clicked" android:textColor="@color/black" android:gravity="center" android:layout_marginTop="20dp"/> <ImageView android:id="@+id/image" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentEnd="true" android:layout_margin="25dp" android:src="@mipmap/ic_launcher_round"/> […]

1 2 3 23

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq