Obsolete
Status Update
Comments
jo...@gmail.com <jo...@gmail.com> #2
Forgot to mention:
Emulator of Android V2.1-update1
API Level: 7
CPU/ABI: ARM(armeabi)
Eclipse Indigo
Emulator of Android V2.1-update1
API Level: 7
CPU/ABI: ARM(armeabi)
Eclipse Indigo
jo...@gmail.com <jo...@gmail.com> #3
Actually I resolved this by using TableRow.LayoutParams instead of TableLayout.LayoutParams. Please close the bug.
ne...@gmail.com <ne...@gmail.com> #4
Try a reboot emulator or even on your device.
Worst case, clean project and try a different emulator version.
Worst case, clean project and try a different emulator version.
br...@gmail.com <br...@gmail.com> #5
You can run into the same issue setting a android:stretchColumns of "*" in an XML file. An example and its explanation is here: http://stackoverflow.com/questions/8163940/by-zero-error-in-xml-file
ba...@gmail.com <ba...@gmail.com> #6
It does still occur in Android 4.x. This condition (no views/rows added to the table yet) should be properly handled in the android code.
jb...@android.com <jb...@android.com> #7
Based on its date, this issue was originally reported before Android 4.x. Because of the many changes that existed in Android 4.x compared to previous versions, it's very likely that this issue doesn't exist in recent versions of Android like 4.2.2 or newer. Because of the high likelihood that this issue is obsolete, it is getting closed automatically by a script, without a human looking at it in detail. If the issue still exists on a Nexus 4 or Nexus 7 running Android 4.2.2 and is not related to Google applications, please open a new report accordingly.
cr...@gmail.com <cr...@gmail.com> #8
This still occurs with the 5.1.1 SDK, with a div by zero crash in TableLayout.mutateColumnsWidth. The findLargestCells method probably should be amended to handle the case where a row has no columns.
Description
Here's the stack trace:
-----------------------------------------------------------------------
08-17 02:23:29.505: ERROR/AndroidRuntime(221): Uncaught handler: thread main exiting due to uncaught exception
08-17 02:23:29.515: ERROR/AndroidRuntime(221): java.lang.ArithmeticException: divide by zero
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.widget.TableLayout.mutateColumnsWidth(TableLayout.java:576)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.widget.TableLayout.shrinkAndStretchColumns(TableLayout.java:565)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.widget.TableLayout.measureVertical(TableLayout.java:463)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.widget.TableLayout.onMeasure(TableLayout.java:428)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.view.View.measure(View.java:7964)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.view.View.measure(View.java:7964)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.widget.LinearLayout.measureVertical(LinearLayout.java:464)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.view.View.measure(View.java:7964)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.view.View.measure(View.java:7964)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.view.ViewRoot.performTraversals(ViewRoot.java:763)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.os.Handler.dispatchMessage(Handler.java:99)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.os.Looper.loop(Looper.java:123)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at android.app.ActivityThread.main(ActivityThread.java:4363)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at java.lang.reflect.Method.invokeNative(Native Method)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at java.lang.reflect.Method.invoke(Method.java:521)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-17 02:23:29.515: ERROR/AndroidRuntime(221): at dalvik.system.NativeStart.main(Native Method)
-----------------------------------------------------------------------
And here's mycode:
-----------------------------------------------------------------------
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//--- Retrieve the extra data that should've been sent with the intent
Bundle extras = getIntent().getExtras();
String bracketName = extras.getString("BracketName");
Integer numTeams = Integer.parseInt(extras.getString("NumTeams"));
String tournamentType = extras.getString("TournamentType");
String opponentAssignment = extras.getString("OpponentAssignment");
//--- If we didn't get the data, go back to the previous activity
if ((bracketName == null) || (numTeams == null) || (tournamentType == null) || (opponentAssignment == null)) {
Intent intent = new Intent(NewBracketActivity2.this, NewBracketActivity1.class);
startActivity(intent);
}
//--- Table layout
TableLayout layout = new TableLayout(this);
layout.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.FILL_PARENT));
layout.setStretchAllColumns(true);
for (Integer i = 1; i <= numTeams; i++) {
//--- Table row
TableRow tableRow = new TableRow(this);
TableLayout.LayoutParams trParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
tableRow.setBaselineAligned(false);
trParams.setMargins(0, 10, 0, 0);
tableRow.setLayoutParams(trParams);
//--- Text view (team number)
TextView textView = new TextView(this, null, android.R.style.TextAppearance_Medium);
TableLayout.LayoutParams tvParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.FILL_PARENT);
Integer textViewID = i + 100;
textView.setText("Team " + i);
textView.setId(textViewID);
tvParams.setMargins(0, 0, 5, 0);
textView.setGravity(Gravity.CENTER);
textView.setLayoutParams(tvParams);
tableRow.addView(textView);
//--- Edit text (team name)
EditText editText = new EditText(this);
RelativeLayout.LayoutParams etParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
etParams.addRule(RelativeLayout.RIGHT_OF, textViewID);
editText.setLayoutParams(etParams);
tableRow.addView(editText);
layout.addView(tableRow);
}
setContentView(layout);
}
-----------------------------------------------------------------------