OnClickListener doesn't fire <p><strong>The problem</strong></p> <p>This code doesn't fire when the button is clicked.</p> <pre><code>mBtnSend = (Button) findViewById(R.id.btnSend); mBtnSend.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view) { mTest= (EditText) findViewById(R.id.txtText); mTest.setText("hello"); } }); </code></pre> <p>The previous code is inside:</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { </code></pre> <p>In <em>MainActivity.java</em> after <em>setContentView(R.layout.main);</em></p> <p>Both variables for button and EditText are declared here:</p> <pre><code>public class MainActivity extends Activity implements IToolbarsContainer, OnTouchListener, IDownloadEventsListener { private Button mBotonEnviar; private EditText mCampoPrueba; </code></pre> <p>And i have:</p> <pre><code>import android.view.View.OnClickListener; </code></pre> <p>This is the complete layout</p> <pre><code>&lt;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:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="org.cade.codigos.ui.activities.RequestData"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Titulo" android:id="@+id/txtTitiulo" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Nombre" android:id="@+id/lblNombre" android:layout_marginTop="40dp" android:layout_below="@+id/txtTitiulo" android:layout_alignParentRight="true" /&gt; &lt;EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textPersonName" android:text="Nombre" android:ems="10" android:id="@+id/txtNombre" android:layout_below="@+id/lblNombre" android:layout_alignParentLeft="true" /&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Apellido" android:id="@+id/lblApellido" android:layout_below="@+id/txtText" android:layout_alignParentLeft="true" /&gt; &lt;EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPersonName" android:text="Apellido" android:ems="10" android:id="@+id/txtApellido" android:layout_below="@+id/lblApellido" android:layout_alignParentLeft="true" /&gt; &lt;Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Send" android:id="@+id/btnSend" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" /&gt; </code></pre> <p></p> <p><strong>Long.. onCreate method for request</strong></p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); INSTANCE = this; Constants.initializeConstantsFromResources(this); Controller.getInstance().setPreferences(PreferenceManager.getDefaultSharedPreferences(this)); if (Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_SHOW_FULL_SCREEN, false)) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } if (Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_GENERAL_HIDE_TITLE_BARS, true)) { requestWindowFeature(Window.FEATURE_NO_TITLE); } setProgressBarVisibility(true); //setContentView(R.layout.main); setContentView(R.layout.activity_request_data); mBotonEnviar = (Button) findViewById(R.id.btnEnviar); mBotonEnviar.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view) { mCampoPrueba = (EditText) findViewById(R.id.txtApellido); mCampoPrueba.setText("hola"); } }); mCircularProgress = getResources().getDrawable(R.drawable.spinner); EventController.getInstance().addDownloadListener(this); mHideToolbarsRunnable = null; mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); buildComponents(); mViewFlipper.removeAllViews(); updateSwitchTabsMethod(); updateBookmarksDatabaseSource(); registerPreferenceChangeListener(); Intent i = getIntent(); if (i.getData() != null) { // App first launch from another app. addTab(false); navigateToUrl(i.getDataString()); } else { // Normal start. int currentVersionCode = ApplicationUtils.getApplicationVersionCode(this); int savedVersionCode = PreferenceManager.getDefaultSharedPreferences(this).getInt(Constants.PREFERENCES_LAST_VERSION_CODE, -1); // If currentVersionCode and savedVersionCode are different, the application has been updated. if (currentVersionCode != savedVersionCode) { // Save current version code. Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit(); editor.putInt(Constants.PREFERENCES_LAST_VERSION_CODE, currentVersionCode); editor.commit(); // Display changelog dialog. Intent changelogIntent = new Intent(this, ChangelogActivity.class); startActivity(changelogIntent); } /* if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(Constants.PREFERENCES_BROWSER_RESTORE_LAST_PAGE, false)) { if (savedInstanceState != null) { String savedUrl = savedInstanceState.getString(Constants.EXTRA_SAVED_URL); if (savedUrl != null) { addTab(false); navigateToUrl(savedUrl); lastPageRestored = true; } } }*/ boolean lastPageRestored = false; // gaf - comienzo con la pagina inicial String savedUrl = "file:///android_asset/startpage/index.html"; //String savedUrl = "http://servidor-cade.com"; //String savedUrl = "http://192.168.1.18:3636"; addTab(false); navigateToUrl(savedUrl); lastPageRestored = false; //if (!lastPageRestored) { // addTab(true); //} } initializeWebIconDatabase(); startToolbarsHideRunnable(); } </code></pre>