FAQ Database Discussion Community


Best place to attach onClickListener in recyclerview

android,onclicklistener,recyclerview
While i was looking at some tutorials about recycler view.some of them used the viewHolder constructor to attach the onClick listener while some of them used the onBindViewHolder method. which method is the best place to attach the onclicklistener. i'm really confused

OnClickListener() in onCreate()?

android,onclicklistener
Would this be an appropriate way of setting up a button for taking a picture? Not trying to start an activity just trying to get the other methods in the activity to run when the button is clicked. Thanks @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera); if(checkCameraHardware(getApplicationContext())){ mCamera = getCameraInstance();...

error: /home/retok/proj/src/com/hellow/app/HelloActivity.java:34: ';' expected

java,android,methods,onclick,onclicklistener
I'm trying to make Android onClick() method easier to read, so I wrap it like this public void click(Button bt) { bt.setOnClickListener(new View.OnClickListener() { public void onClick(View v) {} }); } When I try to run it like this button = (Button) findViewById(R.id.btn1); click(button) { @Override public void onClick(View v)...

ListView & onItemClick - When click, open new activity [on hold]

java,android,listview,android-listview,onclicklistener
actually my ListView is here: ListView lv = (ListView) findViewById(android.R.id.list); ArrayAdapter<String> ad = new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_list_item_1,ls); lv.setAdapter(ad); What I want is when I click on an item in my ListView it should open a new activity for that item where I can show some description of the item e.g. if the...

Implement OnClickListener to the ListView Items

android,mysql,listview,android-arrayadapter,onclicklistener
I have sucessfully got the data from my server and displayed it in my ListView and now i want to implement Click event in the ListView Items. For now i am displaying the "id" and "SomeText" in my List view. My Question is How to implement a Click event in...

Android button onclicklistener animation is not working

android,button,onclicklistener
I am working on android app and my animation is not working when I am clicking on button. Here my codes, //Login layout signup button click listener to hide login layout and show signup layout loginUserSignupBTN.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivityActionFadeInAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void...

onclicklistener for actionbar customview not already showed

android,android-actionbar,onclicklistener
I have two different layouts for my actionbar, each one triggered by the other. The problem is that i can only manage the button in the opening layout, instead when i try to associate onclicklistener to the button in the view not already showed my application crashes. MainActivity: public class...

No such table: (code 1) while compiling: SELECT * FROM event

android,android-listview,onclicklistener
First of all, please do NOT mark this question as duplicate because I have searched through EVERY question that has been asked about this error on stackoverflow, but still nothing helps me. I tried increasing the database version, uninstalling and reinstalling the app, trying different emulators and even tried on...

Q: How to use OnClickListener with HorizontalScrollView

java,android,scrollview,onclicklistener,horizontalscrollview
OnClickListener not working with ScrollView because "extends Fragment". How can I use it with this? An example enough. Thanks.. UPDATE Fragment1.java package intizamyazilim.example; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; /** * Created by Administrator on 26.02.2015. */ public class Fragment1 extends Fragment { @Override...

Android setOnItemClickListener vs setOnClickListener

android,android-listview,onclicklistener,onitemclicklistener
As I know, there are two methods to handle click on different list items: Use setTag() to set types for items of list in Adapter, then setOnItemClickListener() for the list and getTag() of the view to differentiate the type, like this: listview.setOnItemClickListener(new OnItemClcikListener(){}); Inside the adapter, setOnClickListener() individually for each...

Android: Setting ID's for Array of Image Buttons

android,for-loop,onclick,onclicklistener,imagebutton
I am making an android application that allows users to click either a plus or minus image button to change the number displayed in a text view. There are 18 of the text views and a plus and minus image button for each text view. The activity crashes when i...

Implementing View.OnClickListener for the activity - method is not overriden

java,android,onclicklistener
Here is my activity code: public class TextsListActivity extends ActionBarActivity implements View.OnClickListener { @Override public void OnClick(View button) { } } Android Studio warns that Method does not override method from its superclass and also another warning that TextsListActivity should implement onClick. What have I done wrong?...

How to capture Click event of button when its overlapped with Bitmap object

android,onclicklistener
I am trying to capture click even on button when the button and a bitmap objects are overlapped but unable to do so. Here is how my object looks like The green and red portion are part of bitmap image and the blue (Add) is button both have similar properties...

DialogFragment not recognizing finish() method

java,android,fragment,onclicklistener,android-dialogfragment
Hello ultimately what I am looking to do is to have a DialogFragment show on screen to confirm that the user wants to exit the app. If the user says that they do wish to close the app the app shuts down. If the user does not the DialogFragment goes...

Button setOnClickListener method is not invoked

java,android,button,onclicklistener
The below is the sample code I'm trying to get the selected value from spinner on setOnClickListener method for the Button validateUser. public class MainActivity extends Activity implements AdapterView.OnItemSelectedListener { private Button validateUser; private Spinner userTypeSpinner; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); userTypeSpinner=(Spinner)findViewById(R.id.userTypeSpinner); validateUser= (Button) findViewById(R.id.userValidate);...

The difference between a Button and a RadioGroup in referencing

android,onclicklistener,android-button,android-radiobutton,oncheckedchanged
In an android Activity class, I saw the bridging to a Button of XML file and the setting it for click listener was using findViewById(): public class MyClass1 extends Activity implements OnClickListener { Button b; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.photo); b = (Button) findViewById(R.id.button1); //This is where I...

Why does onClick does not fire drag listener, but on Long click works fine?[android]

java,android,onclicklistener,onlongclicklistener
I have apple on screen and i have 2 listeners attached to it: onClickListener, onDragListener. Simple click on apple image does not fire drag, but long click works fine. package nis.drag_apple; import android.app.Activity; import android.content.ClipData; import android.content.ClipDescription; import android.content.Context; import android.media.Image; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.DragEvent; import android.widget.Toast; public...

Android: How to pass parameters from OnClickListener to another

java,android,onclicklistener
I'm new to android and Java. I wanna pass a variable (ac) from OnClickListener to another. I've tried this way, but i receive this error: cannot resolve symbol 'ac'. Can you help me please? Button Calculate = (Button) theLayout.findViewById(R.id.button); Button buttonb = (Button) theLayout.findViewById(R.id.buttonb); final TextView tvac = (TextView) theLayout.findViewById(R.id.tvac);...

Add Cluster Items onClick over Expandable List View

android-activity,maps,cluster-computing,expandablelistview,onclicklistener
First of all I'm sorry for my bad English :X Iam quite a newbie in Android App development and Iam about to develope an app which gives the user informations like free park-places in town. The app is based on Google Maps. My Problem: My app starts and shows a...

Android: How to set onClickListener to different button when clicked

android,button,onclicklistener
I have ten buttons and only one of them has a Red background at any point of time and the red button has an onClicklistener. When this red button is clicked one of these ten buttons in random will get red background and this new red button should use the...

The method onClick(View) of type new OnClickListener(){} must override or implement a supertype method

android,onclicklistener
I am trying to set OnClickListener on the button to get the checked checkboxes but I am getting this Error here how can I fix it? OnClickListener cannot be resolved to a type The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new OnClickListener(){}) -The method...

How to dynamically add listener to button on customAdapter in android

android,onclicklistener,custom-adapter
I want to increment/decrement the count and update it to the database when click on button. the problem is button is on adapter, how should i apply an listener to individual button and update the count for particular user on UI as well as in Database. What I have achieved:...

Trying to get a simple Camera application to work

java,android,camera,onclicklistener
I'm a beginner to Android app development. I'm getting the hang of it, and I've read a lot of tutorials, but I still can't get the camera to work. Basically what I want to do is take a picture, store the image internally within the app and then display that...

Add onClickListener to not exist textView in android

android,jquery,listview,onclicklistener
I am web developer before I heading to android development. I can achieve this with the code below in jquery $(document).on("click",".textView",function(){}); So in android I have a list view that will dynamically load new content from the server. Inside the listView have a textView and some content. So how can...

Unable to get onClick method in Fragment to work using existing solutions

java,android,android-fragments,onclick,onclicklistener
I have a ViewPager that holds three fragments (within a tabbed layout). The third and final fragment holds two ImageButtons (up and down arrows) and an ImageView that cycles through different images depending on which directional arrow is hit. So far, I've been unable to get the onClick methods on...

How to implement button SetOnClickListener in a fragment?

android,eclipse,android-fragments,fragment,onclicklistener
I'm working on a small project and I want to use a Slider Menu. Long story short I happen to find a source code of a slider menu using drawer from some website and it works very well on my device. However I'm a little bit confused migrating my previous...

RecyclerView data are multiple modified/displayed

android,adapter,onclicklistener,recyclerview,android-viewholder
I've a small problem with my RecyclerView. It's well filled by my adapter with some TextViews, an ImageView and some buttons. When there's an OnClick-Event on one of the buttons it modifies a TextView - so far so good but when I'm scrolling some items further another RecyclerView-item is also...

Android: Call and execute a Class on the MainActivity Class

android,onclicklistener,main-activity
I m a beginner to android development. I am trying to create an app that is able to scan QR code. At first I have done everything on the MainActivity and everything works fine but now I need to make a class called QRScanner and then to call on the...

Integer value in TextView won't update; onClickListener won't run code

java,android,xml,integer,onclicklistener
No matter how much I edit or change to my Java code for this assignment, it refused to properly update the value of the integer variable I've set for the result. Can someone show me what on earth I'm missing here? Below is my code: package com.example.minicalc; import com.example.minicalc.R; import...

How to Know What Part of a TextView was Selected

android,android-fragments,textview,onclicklistener
I am populating textviews on the activity dynamically, based on text that is being parsed in from xml articles. The text is formatted using html tags, so I set the text like: textViewBody.setText(Html.fromHtml(content)); The articles are set up to either some text in a body to a website, to another...

Button Click Listener On ListView in a Fragment

android,listview,android-fragments,onclicklistener
So I am trying to add a Button some functionality with an onClickListener but I can't seem to get it to work. My button is declared in the XML of the list item and my list is implemented within a Fragment. I have done some research to find some answers...

Inflater button click listener not work

android,listview,button,onclicklistener,baseadapter
i have one custom listview and i want to give click listener into the Button ui object but it's not working, please kindly go through my below code and suggest me some solution. package com.example.dynamicbutton; import java.util.ArrayList; import android.annotation.SuppressLint; import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import...

Differnce between click event in ListView Android

android,listview,onclicklistener,onitemselectedlistener
I am doing a listView on android to display the list of all collection points, each with area and address, then user can click to each item and delete/edit it. ListView is populated by an array adapter with class Collection point. When I try to set the action for user...

How to get the text onClick on a TextView that is created dynamically?

android,textview,onclicklistener
I have this code so far, to create TextViews with the texts from usernames arrayList. TextView txt_con = null; for(int i=0; i<usernames.size(); i++) { txt_con = new TextView(this); txt_con.setLayoutParams(lparams); txt_con.setPadding(0, 30, 0, 0); txt_con.setText(usernames.get(i)); ll_cont.addView(txt_cont); } and the onClickListener txt_con.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO...

Android do not execute setOnTouchListener if setOnLongClickListener has been executed

java,android,methods,onclick,onclicklistener
I have an app where you can press on a screen and a method gets executed, and where you can long press and another method gets executed. The problem is, when I long press on the screen the normal onClickListener also gets executed, which I don't want. They both are...

Viewholders and setOnClickListeners

android,onclicklistener
I have a RecyclerView with a list of items. The individual list item is an ImageView with a TextView. They have different behaviours when clicked. The individual list item is rendered with the aid of a ViewHolder. Where should I put the .setOnClickListener() call for the ImageView and TextView? In...

Google Maps API - Hyperlink in Map Infoview not opening native GoogleMaps

android,google-maps,hyperlink,google-maps-android-api-2,onclicklistener
I am developing a GoogleMap Map with a custom InfoView. In my InfoView, I want a hyperlink opening the native GoogleMap application with my longitude and latitude on Click. I've tried by using the Common Intents API Guide and creating a hyperlink with this syntax: geo:latitude,longitude and in my code:...

Select CheckBox of all ListViewItem

android,listview,checkbox,onclicklistener
I got a ListActivity with list items I've created. Each item got a CheckBox in it. In addition, the layout got a button which is suppose to simply check all the check boxes, yet it's not working even though the OnClickListener of the button is being called. This a method...

Android ListView OnClickListener

java,android,android-listview,onclicklistener,listviewitem
I need to add a code responsible for action when one row from my list is clicked. I don't know if it should be OnItemClickListener or OnClickListener and how&where to write it. My app is with view holder. Here is my code: public class JobListAdapter extends ArrayAdapter<String> { private LayoutInflater...

LibGDX - How to combine Clicked() method from two click listeners in LibGDX similar to Android?

java,android,onclick,libgdx,onclicklistener
I want to combine the following two buttons (button1 & button2) into one clicked() method which is similar to Android using v.getId(). In LibGDX: button1.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y){ button1.setText("It was the first button."); } }); button2.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float...

ImageView setOnClickListener in a dialog

android,dialog,imageview,onclicklistener
I create a custom dialog box with this method: public Dialog onCreateDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inflater = this.getLayoutInflater(); builder.setView(inflater.inflate(R.layout.dialog_rate, null)) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { SharedPreferences.Editor settingsEditor = settings.edit(); settingsEditor.putBoolean("rate",false); settingsEditor.apply(); Intent intent = new Intent();...

RecyclerView onItemClicked callback

android,onclick,onclicklistener,recyclerview,android-recyclerview
I am implementing a Navigation Drawer with a RecyclerView, using this tutorial, but I don't want to apply the whole tutorial, I just want to handle the user's click. I've implemented the onClickListener inside the ViewHolder of my MyAdapter class: public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener{ int...

Listview onClickListener is not working in Drawer Layout

android,android-listview,onclicklistener,navigation-drawer
I am making a drawer having ListView in it. But surprisingly its not getting any onClickListener fired when I click on any list item. I have tried these things till now Making a ArrayAdapter for ListView and get simply list.onItemClickListener and list.onClickListener too. A custom adapter with a implemented OnClickListener...

Setting onClick event for Custom Action Bar items

android,android-actionbar,onclicklistener
I am getting following exception when I am trying to add onClick event on the item of Custom ActionBar.My app crashes when I click on searchiconactionbar in ActionBar.I have put method onClick() in activity only.Why am I getting this error?Is there any other way for setting the onClickListener for Custom...

How can I get the value from TextView with OnClickListener?

java,android,onclicklistener
I have this code to create a dynamic table. Now I want to attach to every TextView an event at onClick. When I tap on a TextView, I want to get the value and execute a method. So this is my code: TableLayout ll=(TableLayout) view.findViewById(R.id.displayLinear); TableRow.LayoutParams rowParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,...

Using Android AdapterView.OnItemClick Listener to redirect to a new blank activity

java,android,listview,adapter,onclicklistener
Hey so I followed a tutorial and constructed a list view. everything is populated and want to click on one of the items and redirect it to another blank activity. All of the items in the list view are made and populated in my Dashboard Class: import android.app.AlertDialog; import android.content.DialogInterface;...

Android-One clicklistener for many CheckBoxPreference

android,onclick,onclicklistener,checkboxpreference
I have some CheckBoxPreference elements for which I would like to use one onClickListener for all the CheckBoxPreference in my page. Here is what I'm trying to do: CheckBoxPreference checkboxPref = (CheckBoxPreference)getPreferenceManager().findPreference("preference1"); CheckBoxPreference checkboxPref1 = (CheckBoxPreference)getPreferenceManager().findPreference("preference2"); checkboxPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) {...

OnClickListener in Android Fragment

java,android,android-fragments,onclicklistener
I am developing a simple Android Application with 2 tabs. I have implemented the Tabs very well. Tab1 consists of Fragment 1 Tab2 consists of Fragment 2 Now i want to add a button in Fragment 1, and when the user clicks on that button, some activity is displayed. I...

Implement DialogFragment interface in OnClickListener

java,android,android-listview,onclicklistener,android-dialogfragment
I need to build a DialogFragment which returns user input from the dialog to an activity. The dialog needs to be called in an OnClickListener which gets called when an element in a listview gets clicked. The return value of the DialogFragment (the input of the user) should be directly...

OnclickListner on a custom listview adapter

android,android-listview,android-view,onclicklistener,baseadapter
I am newbie to Android so you can expect this a little silly but please do help. I have somewhat like custom listviews of people similar to whatsapp and other IM apps etc. Now when i click the listview i want to get the respective id of the clicked listview....

How to get only a specific button's click

android,button,android-intent,onclicklistener
I have 2 buttons on the MainActivity. I want the first button to send me to TestPage1.class(Which it already does). And I want the second button to send me to TestPage2.class. Whenever I click on the second button, it sends me straight to TestPage1 and not TestPage2. How can I...

DialogInterface.OnClickListener error for alert button

java,android,onclicklistener
When trying to set on click listener on dialog button get error: Class 'Anonymous class defived from OnClickListener' must either be declared abstract or impement abstract method 'onClick(DialogInterface, int)' in 'OnClickListener' Could someone please tell me why this is not working? import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import...

Javascript - Too much click listener in app

javascript,jquery,events,actionlistener,onclicklistener
I have a general question about javascript (jQuery) events/listener. Is there any limit for the number of click listener without getting performance problems? Thank you for your help! I would appreciate every answer....

Android onItemLongClick adds position to the arrayList in different activity

android,listview,android-arrayadapter,onclicklistener,onitemlongclicklistener
I have got two activities. My goal is: After longClick on any ListView position in activity 2, I want some String to be added to ListView in activity 1. From activity 2 I'm going back to activity 1 by pressing back button. Each ListView has got different adapter. I tried...

Create android menu via set on click listener

android,onclick,onclicklistener
I want create list menu simple : About , Contact us And more ( about 30-40 button ) After click on this buttons , i want start new activity I want this code in use class and out of mainactivity My xml code : http://i.stack.imgur.com/3moSl.png clcAbout , clcContact and clcFB...

How to open a activity from a list view which shows googe map?

android,list,google-maps,onclicklistener
I am new on building android and i've been trying to open a new activity from a row of list, where each activity displays google map of each row. So far I have manage to open a new activity by clicking row, but I have no idea how do I...

Cards dont show visual feedback

android,onclicklistener,android-cardview
I have a recycler adapter full of cards. The cards themselves work fine. However when i click the card it does not show any visual feedback its being clicked. Is there something im missing? I also would appreciate a tutorial on mateial design animation. The android developer site didnt really...

Random sound play on button touch

android,onclicklistener
I want my button to play a different sound each time it is being touched. For now the button plays one sound when it is touched. I used the onClickListener, and inside it I used the MediaPlayer to play the mp3 sound, the code is the following: pressMe.setOnClickListener (new View.onClickListener...

Android- Logic behind setOnClickListener

java,android,onclicklistener
I am new to Java/Android programming and unfortunately I don't fully under stand the logic behind this piece of code: button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click } }); I have alredy read a whole lot of tutorials about it but unfortunately in no...

How to change to another Activity when pressing on a Gridviewpager?

android,onclicklistener,android-gridview,android-wear
I am trying to start a new certain Activity based on which page I am clicking on in a Gridview. I tried to understand the Sample GridViewPager which is coming along with the sdk and trying to adapt the given explanation. But I really don't know how to bring these...

Need working example of EventFiringWebDriver and OnFindingElement or OnElementClicked usage in Selenium C#?

c#,selenium,selenium-webdriver,onclicklistener
I am a novice to both Selenium and C#. Can someone please help me with an working example of how to write a message to a log file or Console.WriteLine upon clicking an element or finding an element using EventFiringWebDriver? I am looking for C# and not Java.

How do I make a Dialog Box work inside an onClick Listener in a Fragment in Android?

java,android,dialog,onclicklistener
I am trying to build an android app and have come across a situation where I want a user to navigate between Dates by clicking Previous (Month) and Next (Month) buttons. I however do not want the user to go to a month after the current month. I would like...

onclickListener for actionbar elements

android,android-actionbar,onclicklistener
I have two different layouts for my actionbar, each one triggered by the other. for the first one i can easy declare onclicklister in the oncreate method. For the second one i have to associate the listener inside the first onclicklistener because is the right time to do it, when...

onClickListiner not working

java,android,onclicklistener
<FrameLayout android:id="@+id/comment_container" android:layout_width="match_parent" android:layout_height="271dp"> <Button style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add Comment" android:id="@+id/comment_add" android:layout_gravity="right|top" android:clickable="true" android:enabled="true" /> <EditText android:layout_width="253dp" android:layout_height="48dp" android:id="@+id/comment_text"...

Disable onClicklistner while other touch listner is active

android,android-layout,onclicklistener,ontouchlistener
I am trying to implement UI like google keep. In the main layout there is frame layout in which there is a FAM(Floating Actions Menu) and a blackshadow view which is visible when FAM is expanded. What i want is that when i touch the shadow view it should Collapse...

Change Fragment on button click

android,android-fragments,onclicklistener
I'm triying to change the fragment when I click a button. But nothing happends, I don't know if the problem is on the button click or when I try to change the fragment.. I have a navigationDrawer and when I click on the 3 section I change the fragment of...

onClick in fragments of Navigation Drawer

android,android-fragments,onclicklistener,navigation-drawer
I've been searching through all the questions for a while and I'm still stuck. I cant figure out how to add a button link in a fragment of an navigation drawer linking to another fragment not a member of the navigation drawer. I've tried implementing the OnClickListener, i know fragments...

Setting a click listenner to markushi/android-circlebutton

android,onclicklistener
I want to set a click listener to this circular button. I am using Android Studio 1.1.0 and the app runs, but throws an exception and crashes, both on an emulator and on a Nexus 5 (using API 21). Any idea what is causing this? The button is inside a...

Boolean value not being set upon onClickListener

java,android,textview,onclicklistener
I have two classes. I am trying to change a boolean value depending on if the user clicks a checkbox. Then, depending on whether that value is true/false (whether the checkbox was checked or not), I want to display specific text in a textview. Here is the MainActivity class: public...

How to display image and text from Cardview in another activity onClick?

android,onclicklistener,android-cardview,android-viewholder,android-recyclerview
I have a sample app from exoguru which contains cardview each card consists of an image and corresponding text .Now how to display that image and text in another activity on clicking that particular card? Here is the screenshot Here is the ViewHolder which contains the onclick for the cardview...

Proper usage of OnClickListener Android

java,android,onclicklistener,android-tabs
I am new to Android Development and I am trying a simple program with Tabs.. MainActivity.java protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button b1 = (Button)findViewById(R.id.b1); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(),"Done", Toast.LENGTH_LONG).show(); } }); // Create the adapter that will return a fragment for...

Null pointer Exception on .setOnClickListener

java,android,nullpointerexception,onclicklistener
I am having an issue with a click listener for a login modal submit button. This is the error. Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference I have a reasonable understanding of what a null pointer exception is and I have search...

OntouchListener adding too many values to array

java,android,arraylist,onclicklistener,ontouchlistener
For an app I am working on I need to use OntouchListeners so that the transparent area of my button is not clickable but this is throwing a problem I wasn't expecting. When I press the button more than one value is stored each time. Here is my code: private...

Android: OnClickListener of Button on CardView

onclicklistener,android-context,android-cardview,android-recyclerview
I'm a bit of a newbie so I apologize if this is an easy question. I'm following this tutorial: http://www.truiton.com/2015/03/android-cardview-example/#comment-7174 It shows how to make a few CardViews in a layout with 2 TextViews in each - all programmatically. I would like to modify it to have a Button instead...

OnClickListener calling wrong case

android,onclicklistener
I have a listView that is using a CustomAdapter and the listView Item contains a button, I made an OnClickListener in the CustomAdapter to handle the button depending on it's position buy using a switch(position) and all the cases are working fine except for the last one which is case...

Android ImageButton ClickEvent not working

android,onclicklistener,android-imagebutton
here is the code, please can anyone simply tell me how to make the onClick event run? xml file of the activity, which has a navigation-drawer fragment, An Image view, A TextView, An ImageButton <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include android:id="@+id/app_bar" layout="@layout/app_bar" />...

How to manage OnClickListener on multiples buttons automatically created

java,android,android-layout,onclicklistener
I have a lot of Buttons that I've created programatically, each button corresponds to a certain action, and I need to be able to identify and retrieve the user input based on which button was clicked. The UI is as follow: I have like 70 items like those ones. I've...

Android Fragment Layout Listeners

java,android-fragments,onclicklistener
I have code that inflates particular fragments based on user choices. I want to set an onCliclListener to a button in a particular fragment layout but I don't know which java file to do so in. I assume it's the fragment java file but I can't initialize the button. Here...

Android Get selected item on click listeners

android,listview,view,onclicklistener
Goys I use the following for an on click listener lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { TextView textview1 = (TextView) findViewById(R.id.textView1); TextView textview2 = (TextView) findViewById(R.id.Sr2); TextView textview3 = (TextView) findViewById(R.id.Sr3); TextView textview4 = (TextView) findViewById(R.id.Sr4); TextView textview5 = (TextView) findViewById(R.id.Sr5);...