Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid EditText Disappears after pressing Button in TableLayout
    text
    copied!<p><strong>Some Background</strong><br /> I have a TableLayout with 9 rows. I chose the TableLayout because I could successfully line up EditText views next to each other on 1 row. I have 6 EditText on two rows as you will see below, but to avoid repetitiveness I am only going to include 2 of the 6 to save on space and I removed some of the unecessary rows because they were displaying properly (just TextView).</p> <p><strong>The Problem</strong><br /> The problem I am having is after I press the Button on my layout, all of the EditText views disappear. My button initiates contact to a WCF Restful Service, but does so using an AsyncTask. There is a wait dialog to occupy the user and sometimes toast messages pop up. This is all normal behavior. To be perfectly the EditText disappear immediately after I press the button.</p> <p>I have searched with google and stackoverflow and I have seen similar problems, but not the same problem that I am having. What is very weird is this only happens when I am debugging on my phone, it doesn't happen in the AVD emulator.</p> <p><strong>Stats</strong><br /> Phone: T-Mobile myTouchQ LG-C800 (FYI: not the greatest phone) I rooted it.<br /> Phone Android Version: 2.3.4 (LG Doesn't believe in updates apparently)<br /> IDE: IntelliJ 11.1<br /> Android SDK : 4.0.3<br /> Java Version: 1.7<br /></p> <p><strong>Questions</strong><br /> 1. Should I use a different layout?<br /> 2. Any clue why this is happening?</p> <p>Here is shortened version of my Layout.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TableRow android:id="@+id/rowTitleWinningNumbers" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="0dip" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Winning Numbers" /&gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/rowWinningNumbers" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="0dip" &gt; &lt;EditText android:id="@+id/txtLotto1" android:inputType="text" android:layout_width="0dp" android:layout_weight="16.67" android:editable="false" android:focusable="false" /&gt; &lt;EditText android:id="@+id/txtLotto2" android:inputType="text" android:layout_width="0dp" android:layout_weight="16.67" android:editable="false" android:focusable="false" /&gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/rowTitlePlayerNumbers" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="0dip" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Your Numbers" /&gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/rowPlayerNumbers" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="0dip" &gt; &lt;EditText android:id="@+id/txtPlayer1" android:inputType="text" android:layout_width="0dp" android:layout_weight="16.67" android:hint="@string/strDefaultNumber" /&gt; &lt;EditText android:id="@+id/txtPlayer2" android:inputType="text" android:layout_width="0dp" android:layout_weight="16.67" android:hint="@string/strDefaultNumber" /&gt; &lt;/TableRow&gt; &lt;TableRow android:id="@+id/rowPlayerStatus2" android:layout_height="wrap_content" android:layout_width="wrap_content" android:gravity="center"&gt; &lt;Button android:id="@+id/btnSubmit" android:text="Did I Win?!" android:onClick="btnSubmit_onClick" /&gt; &lt;CheckBox android:id="@+id/cbxSavePlayerNumbers" android:layout_height="wrap_content" android:layout_width="wrap_content" android:gravity="center" android:lines="2" android:text="Save my \nNumbers" /&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; </code></pre> <p><strong>EDIT</strong> The code as requested in the comments</p> <pre><code>public void btnSubmit_onClick(View v) { try { clearStatuses(); setLabelText(R.id.lblTimeStamp, DateTime.Today().toString()); savePlayerNumbers(); //This method has to perform its main task asynchronously getWinningLotteryNumbers(); } catch(Exception ex) { ex.toString(); } } private void getWinningLotteryNumbers() { try { _waitDialog = ProgressDialog.show(MyActivity.this, "Working", "Getting latest Lottery drawing, Please Wait...", true); getButton(R.id.btnSubmit).setEnabled(false); String strUrl = getRString(R.string.strWCFServiceURL); new LottoProxy().execute(strUrl); } catch (Exception e) { resetControlStates(); } } private void clearStatuses() { TextView lblStatus = getLabel(R.id.lblStatus); lblStatus.setText(""); lblStatus.setTextColor(Color.BLACK); for (int i = 0; i &lt; 6; i++) resetTextBoxBackResource(getWinningBox(i), getPlayerBox(i)); } </code></pre> <p>I am supremely stuck on this, so thank you in advance for your help. This is my first real app (as opposed to just playing around), so if I made a novice mistake please let me know.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload