Button not responding to onClick method
up vote
-2
down vote
favorite
I am developing an Android app and I want to inflate a dialog with the press of a button (I've already done that), but one specific button does not work, and I don't really know why.
My code:
public class SearchUser extends AppCompatActivity
private static final String TAG = "SearchUser";
@Override
public void onCreate(@Nullable Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.btnSearchUser);
b.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
AlertDialog.Builder mBuilder = new AlertDialog.Builder(SearchUser.this);
View mView = getLayoutInflater().inflate(R.layout.searchpopup, null);
mBuilder.setView(mView);
AlertDialog dialog = mBuilder.create();
btnSearch.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
);
);
dialog.show();
);
LAYOUT XML FILE:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="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">
<Button
android:id="@+id/btnUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/user"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="0.0"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="@+id/mapView"
mapbox:layout_constraintVertical_bias="0.0" />
<Button
android:id="@+id/btnSearchUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/search_user"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="0.0"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="@+id/mapView"
mapbox:layout_constraintVertical_bias="0.129" />
<Button
android:id="@+id/logoutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/log_out"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="1.0"
mapbox:layout_constraintStart_toStartOf="@+id/mapView"
mapbox:layout_constraintTop_toTopOf="parent"
mapbox:layout_constraintVertical_bias="0.0" />
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="parent"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="parent"
mapbox:mapbox_cameraTargetLat="-34.6131500"
mapbox:mapbox_cameraTargetLng="-58.3772300"
mapbox:mapbox_cameraZoom="12"
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v10">
</com.mapbox.mapboxsdk.maps.MapView>
<Button
android:id="@+id/startButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:enabled="true"
android:text="@string/crear_fiesta"
android:textColor="@color/mapboxGrayLight"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="parent"
mapbox:layout_constraintStart_toStartOf="parent" />
I have tried putting a toast message inside the onClick method but nothing happens, so I guess it just does not enter there.
Anyone know why? Thanks for any answer :D
java
add a comment |
up vote
-2
down vote
favorite
I am developing an Android app and I want to inflate a dialog with the press of a button (I've already done that), but one specific button does not work, and I don't really know why.
My code:
public class SearchUser extends AppCompatActivity
private static final String TAG = "SearchUser";
@Override
public void onCreate(@Nullable Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.btnSearchUser);
b.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
AlertDialog.Builder mBuilder = new AlertDialog.Builder(SearchUser.this);
View mView = getLayoutInflater().inflate(R.layout.searchpopup, null);
mBuilder.setView(mView);
AlertDialog dialog = mBuilder.create();
btnSearch.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
);
);
dialog.show();
);
LAYOUT XML FILE:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="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">
<Button
android:id="@+id/btnUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/user"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="0.0"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="@+id/mapView"
mapbox:layout_constraintVertical_bias="0.0" />
<Button
android:id="@+id/btnSearchUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/search_user"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="0.0"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="@+id/mapView"
mapbox:layout_constraintVertical_bias="0.129" />
<Button
android:id="@+id/logoutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/log_out"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="1.0"
mapbox:layout_constraintStart_toStartOf="@+id/mapView"
mapbox:layout_constraintTop_toTopOf="parent"
mapbox:layout_constraintVertical_bias="0.0" />
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="parent"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="parent"
mapbox:mapbox_cameraTargetLat="-34.6131500"
mapbox:mapbox_cameraTargetLng="-58.3772300"
mapbox:mapbox_cameraZoom="12"
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v10">
</com.mapbox.mapboxsdk.maps.MapView>
<Button
android:id="@+id/startButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:enabled="true"
android:text="@string/crear_fiesta"
android:textColor="@color/mapboxGrayLight"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="parent"
mapbox:layout_constraintStart_toStartOf="parent" />
I have tried putting a toast message inside the onClick method but nothing happens, so I guess it just does not enter there.
Anyone know why? Thanks for any answer :D
java
your layout xml file?
– Ramees Thattarath
Nov 10 at 19:28
That code, as posted, will not compile. Please provide a Minimal, Complete, and Verifiable example. Furthermore, it's unclear exactly what the issue is. Please be specific.
– Mike M.
Nov 10 at 19:30
1
you have usedbtnSearchbut not initialized it anywhere before using it.
– Rahul Kumar
Nov 10 at 19:54
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I am developing an Android app and I want to inflate a dialog with the press of a button (I've already done that), but one specific button does not work, and I don't really know why.
My code:
public class SearchUser extends AppCompatActivity
private static final String TAG = "SearchUser";
@Override
public void onCreate(@Nullable Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.btnSearchUser);
b.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
AlertDialog.Builder mBuilder = new AlertDialog.Builder(SearchUser.this);
View mView = getLayoutInflater().inflate(R.layout.searchpopup, null);
mBuilder.setView(mView);
AlertDialog dialog = mBuilder.create();
btnSearch.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
);
);
dialog.show();
);
LAYOUT XML FILE:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="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">
<Button
android:id="@+id/btnUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/user"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="0.0"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="@+id/mapView"
mapbox:layout_constraintVertical_bias="0.0" />
<Button
android:id="@+id/btnSearchUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/search_user"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="0.0"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="@+id/mapView"
mapbox:layout_constraintVertical_bias="0.129" />
<Button
android:id="@+id/logoutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/log_out"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="1.0"
mapbox:layout_constraintStart_toStartOf="@+id/mapView"
mapbox:layout_constraintTop_toTopOf="parent"
mapbox:layout_constraintVertical_bias="0.0" />
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="parent"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="parent"
mapbox:mapbox_cameraTargetLat="-34.6131500"
mapbox:mapbox_cameraTargetLng="-58.3772300"
mapbox:mapbox_cameraZoom="12"
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v10">
</com.mapbox.mapboxsdk.maps.MapView>
<Button
android:id="@+id/startButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:enabled="true"
android:text="@string/crear_fiesta"
android:textColor="@color/mapboxGrayLight"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="parent"
mapbox:layout_constraintStart_toStartOf="parent" />
I have tried putting a toast message inside the onClick method but nothing happens, so I guess it just does not enter there.
Anyone know why? Thanks for any answer :D
java
I am developing an Android app and I want to inflate a dialog with the press of a button (I've already done that), but one specific button does not work, and I don't really know why.
My code:
public class SearchUser extends AppCompatActivity
private static final String TAG = "SearchUser";
@Override
public void onCreate(@Nullable Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.btnSearchUser);
b.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
AlertDialog.Builder mBuilder = new AlertDialog.Builder(SearchUser.this);
View mView = getLayoutInflater().inflate(R.layout.searchpopup, null);
mBuilder.setView(mView);
AlertDialog dialog = mBuilder.create();
btnSearch.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
);
);
dialog.show();
);
LAYOUT XML FILE:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="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">
<Button
android:id="@+id/btnUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/user"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="0.0"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="@+id/mapView"
mapbox:layout_constraintVertical_bias="0.0" />
<Button
android:id="@+id/btnSearchUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/search_user"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="0.0"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="@+id/mapView"
mapbox:layout_constraintVertical_bias="0.129" />
<Button
android:id="@+id/logoutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/log_out"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="@+id/mapView"
mapbox:layout_constraintHorizontal_bias="1.0"
mapbox:layout_constraintStart_toStartOf="@+id/mapView"
mapbox:layout_constraintTop_toTopOf="parent"
mapbox:layout_constraintVertical_bias="0.0" />
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="parent"
mapbox:layout_constraintStart_toStartOf="parent"
mapbox:layout_constraintTop_toTopOf="parent"
mapbox:mapbox_cameraTargetLat="-34.6131500"
mapbox:mapbox_cameraTargetLng="-58.3772300"
mapbox:mapbox_cameraZoom="12"
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v10">
</com.mapbox.mapboxsdk.maps.MapView>
<Button
android:id="@+id/startButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:enabled="true"
android:text="@string/crear_fiesta"
android:textColor="@color/mapboxGrayLight"
mapbox:layout_constraintBottom_toBottomOf="parent"
mapbox:layout_constraintEnd_toEndOf="parent"
mapbox:layout_constraintStart_toStartOf="parent" />
I have tried putting a toast message inside the onClick method but nothing happens, so I guess it just does not enter there.
Anyone know why? Thanks for any answer :D
java
java
edited Nov 13 at 22:36
shashank chandak
160111
160111
asked Nov 10 at 19:27
Franco Estevez
85
85
your layout xml file?
– Ramees Thattarath
Nov 10 at 19:28
That code, as posted, will not compile. Please provide a Minimal, Complete, and Verifiable example. Furthermore, it's unclear exactly what the issue is. Please be specific.
– Mike M.
Nov 10 at 19:30
1
you have usedbtnSearchbut not initialized it anywhere before using it.
– Rahul Kumar
Nov 10 at 19:54
add a comment |
your layout xml file?
– Ramees Thattarath
Nov 10 at 19:28
That code, as posted, will not compile. Please provide a Minimal, Complete, and Verifiable example. Furthermore, it's unclear exactly what the issue is. Please be specific.
– Mike M.
Nov 10 at 19:30
1
you have usedbtnSearchbut not initialized it anywhere before using it.
– Rahul Kumar
Nov 10 at 19:54
your layout xml file?
– Ramees Thattarath
Nov 10 at 19:28
your layout xml file?
– Ramees Thattarath
Nov 10 at 19:28
That code, as posted, will not compile. Please provide a Minimal, Complete, and Verifiable example. Furthermore, it's unclear exactly what the issue is. Please be specific.
– Mike M.
Nov 10 at 19:30
That code, as posted, will not compile. Please provide a Minimal, Complete, and Verifiable example. Furthermore, it's unclear exactly what the issue is. Please be specific.
– Mike M.
Nov 10 at 19:30
1
1
you have used
btnSearch but not initialized it anywhere before using it.– Rahul Kumar
Nov 10 at 19:54
you have used
btnSearch but not initialized it anywhere before using it.– Rahul Kumar
Nov 10 at 19:54
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
You're overriding the wrong onCreate(), replace it with:
protected void onCreate(@Nullable Bundle savedInstanceState)
Edit: are you sure that this xml should be inflated in class SearchUser?
Do you have a class MainActivity like the xml states?
Tried this but did not solve the problem :/
– Franco Estevez
Nov 10 at 19:49
see my edited answer
– forpas
Nov 10 at 19:53
Yes I do have a class Main Activity, but does that mean that I cant use a button from the activity_main in another class?
– Franco Estevez
Nov 10 at 20:17
Soactivity_main.xmlis used for 2 activities?
– forpas
Nov 10 at 20:20
Yes, it should be. But I guess the problem is there. I have just investigated and in the xml file there is a line that says tools:context=".MainActivity". I think this has to do with the stuff that will work on that xml, and that is why its not working. Any idea?
– Franco Estevez
Nov 10 at 20:25
|
show 1 more comment
up vote
0
down vote
Place the btnSearchUser button below the MapView in XML.
You've also configured MapView with match_parent, which is not applicable to a constraint layout parent. Set the height and width of MapView to 0dp as well.
That shouldnt make sense, I also have two buttons on top of the mapview and they do work.
– Franco Estevez
Nov 10 at 20:20
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You're overriding the wrong onCreate(), replace it with:
protected void onCreate(@Nullable Bundle savedInstanceState)
Edit: are you sure that this xml should be inflated in class SearchUser?
Do you have a class MainActivity like the xml states?
Tried this but did not solve the problem :/
– Franco Estevez
Nov 10 at 19:49
see my edited answer
– forpas
Nov 10 at 19:53
Yes I do have a class Main Activity, but does that mean that I cant use a button from the activity_main in another class?
– Franco Estevez
Nov 10 at 20:17
Soactivity_main.xmlis used for 2 activities?
– forpas
Nov 10 at 20:20
Yes, it should be. But I guess the problem is there. I have just investigated and in the xml file there is a line that says tools:context=".MainActivity". I think this has to do with the stuff that will work on that xml, and that is why its not working. Any idea?
– Franco Estevez
Nov 10 at 20:25
|
show 1 more comment
up vote
0
down vote
You're overriding the wrong onCreate(), replace it with:
protected void onCreate(@Nullable Bundle savedInstanceState)
Edit: are you sure that this xml should be inflated in class SearchUser?
Do you have a class MainActivity like the xml states?
Tried this but did not solve the problem :/
– Franco Estevez
Nov 10 at 19:49
see my edited answer
– forpas
Nov 10 at 19:53
Yes I do have a class Main Activity, but does that mean that I cant use a button from the activity_main in another class?
– Franco Estevez
Nov 10 at 20:17
Soactivity_main.xmlis used for 2 activities?
– forpas
Nov 10 at 20:20
Yes, it should be. But I guess the problem is there. I have just investigated and in the xml file there is a line that says tools:context=".MainActivity". I think this has to do with the stuff that will work on that xml, and that is why its not working. Any idea?
– Franco Estevez
Nov 10 at 20:25
|
show 1 more comment
up vote
0
down vote
up vote
0
down vote
You're overriding the wrong onCreate(), replace it with:
protected void onCreate(@Nullable Bundle savedInstanceState)
Edit: are you sure that this xml should be inflated in class SearchUser?
Do you have a class MainActivity like the xml states?
You're overriding the wrong onCreate(), replace it with:
protected void onCreate(@Nullable Bundle savedInstanceState)
Edit: are you sure that this xml should be inflated in class SearchUser?
Do you have a class MainActivity like the xml states?
edited Nov 10 at 19:52
answered Nov 10 at 19:37
forpas
4,3571216
4,3571216
Tried this but did not solve the problem :/
– Franco Estevez
Nov 10 at 19:49
see my edited answer
– forpas
Nov 10 at 19:53
Yes I do have a class Main Activity, but does that mean that I cant use a button from the activity_main in another class?
– Franco Estevez
Nov 10 at 20:17
Soactivity_main.xmlis used for 2 activities?
– forpas
Nov 10 at 20:20
Yes, it should be. But I guess the problem is there. I have just investigated and in the xml file there is a line that says tools:context=".MainActivity". I think this has to do with the stuff that will work on that xml, and that is why its not working. Any idea?
– Franco Estevez
Nov 10 at 20:25
|
show 1 more comment
Tried this but did not solve the problem :/
– Franco Estevez
Nov 10 at 19:49
see my edited answer
– forpas
Nov 10 at 19:53
Yes I do have a class Main Activity, but does that mean that I cant use a button from the activity_main in another class?
– Franco Estevez
Nov 10 at 20:17
Soactivity_main.xmlis used for 2 activities?
– forpas
Nov 10 at 20:20
Yes, it should be. But I guess the problem is there. I have just investigated and in the xml file there is a line that says tools:context=".MainActivity". I think this has to do with the stuff that will work on that xml, and that is why its not working. Any idea?
– Franco Estevez
Nov 10 at 20:25
Tried this but did not solve the problem :/
– Franco Estevez
Nov 10 at 19:49
Tried this but did not solve the problem :/
– Franco Estevez
Nov 10 at 19:49
see my edited answer
– forpas
Nov 10 at 19:53
see my edited answer
– forpas
Nov 10 at 19:53
Yes I do have a class Main Activity, but does that mean that I cant use a button from the activity_main in another class?
– Franco Estevez
Nov 10 at 20:17
Yes I do have a class Main Activity, but does that mean that I cant use a button from the activity_main in another class?
– Franco Estevez
Nov 10 at 20:17
So
activity_main.xml is used for 2 activities?– forpas
Nov 10 at 20:20
So
activity_main.xml is used for 2 activities?– forpas
Nov 10 at 20:20
Yes, it should be. But I guess the problem is there. I have just investigated and in the xml file there is a line that says tools:context=".MainActivity". I think this has to do with the stuff that will work on that xml, and that is why its not working. Any idea?
– Franco Estevez
Nov 10 at 20:25
Yes, it should be. But I guess the problem is there. I have just investigated and in the xml file there is a line that says tools:context=".MainActivity". I think this has to do with the stuff that will work on that xml, and that is why its not working. Any idea?
– Franco Estevez
Nov 10 at 20:25
|
show 1 more comment
up vote
0
down vote
Place the btnSearchUser button below the MapView in XML.
You've also configured MapView with match_parent, which is not applicable to a constraint layout parent. Set the height and width of MapView to 0dp as well.
That shouldnt make sense, I also have two buttons on top of the mapview and they do work.
– Franco Estevez
Nov 10 at 20:20
add a comment |
up vote
0
down vote
Place the btnSearchUser button below the MapView in XML.
You've also configured MapView with match_parent, which is not applicable to a constraint layout parent. Set the height and width of MapView to 0dp as well.
That shouldnt make sense, I also have two buttons on top of the mapview and they do work.
– Franco Estevez
Nov 10 at 20:20
add a comment |
up vote
0
down vote
up vote
0
down vote
Place the btnSearchUser button below the MapView in XML.
You've also configured MapView with match_parent, which is not applicable to a constraint layout parent. Set the height and width of MapView to 0dp as well.
Place the btnSearchUser button below the MapView in XML.
You've also configured MapView with match_parent, which is not applicable to a constraint layout parent. Set the height and width of MapView to 0dp as well.
edited Nov 11 at 1:03
Avery
4915
4915
answered Nov 10 at 19:58
Ramees Thattarath
186111
186111
That shouldnt make sense, I also have two buttons on top of the mapview and they do work.
– Franco Estevez
Nov 10 at 20:20
add a comment |
That shouldnt make sense, I also have two buttons on top of the mapview and they do work.
– Franco Estevez
Nov 10 at 20:20
That shouldnt make sense, I also have two buttons on top of the mapview and they do work.
– Franco Estevez
Nov 10 at 20:20
That shouldnt make sense, I also have two buttons on top of the mapview and they do work.
– Franco Estevez
Nov 10 at 20:20
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242636%2fbutton-not-responding-to-onclick-method%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
your layout xml file?
– Ramees Thattarath
Nov 10 at 19:28
That code, as posted, will not compile. Please provide a Minimal, Complete, and Verifiable example. Furthermore, it's unclear exactly what the issue is. Please be specific.
– Mike M.
Nov 10 at 19:30
1
you have used
btnSearchbut not initialized it anywhere before using it.– Rahul Kumar
Nov 10 at 19:54